?
Solved

XML: incomplete content error

Posted on 2009-02-12
8
Medium Priority
?
568 Views
Last Modified: 2012-05-06
I am looking at this tutorial:
http://www.codeproject.com/KB/aspnet/xmlguestbook.aspx

The very last line:
</NewDataSet>

Gives this error:
The element 'NewDataSet' h as incplete content. List of possible elements expected: 'guestbook'.

What is wrong with this example? How do I fix it?

thanks.

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
    <xs:schema id="NewDataSet" xmlns=""
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
        <xs:element name="NewDataSet" msdata:IsDataSet="true">
            <xs:complexType>
                <xs:choice maxOccurs="unbounded">
                    <xs:element name="guestbook">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="id" msdata:AutoIncrement="true"
                                msdata:AutoIncrementSeed="1" type="xs:int" />
                                <xs:element name="datetime" type="xs:dateTime"
                                minOccurs="0" />
                                <xs:element name="author" type="xs:string"
                                minOccurs="0" />
                                <xs:element name="subject" type="xs:string"
                                minOccurs="0" />
                                <xs:element name="comments" type="xs:string"
                                minOccurs="0" />
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:choice>
            </xs:complexType>
            <xs:unique name="Constraint1" msdata:PrimaryKey="true">
                <xs:selector xpath=".//guestbook" />
                <xs:field xpath="id" />
            </xs:unique>
        </xs:element>
    </xs:schema>
</NewDataSet>

Open in new window

0
Comment
Question by:Starr Duskk
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 25

Accepted Solution

by:
apeter earned 1400 total points
ID: 23624571
You have defined only the schema but the content xml is missing. Below is the valid XML.


<?xml version="1.0" standalone="yes"?>
<NewDataSet>
      <xs:schema id="NewDataSet" xmlns=""
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
            <xs:element name="NewDataSet" msdata:IsDataSet="true">
                  <xs:complexType>
                        <xs:choice maxOccurs="unbounded">
                              <xs:element name="guestbook">
                                    <xs:complexType>
                                          <xs:sequence>
                                                <xs:element name="id" msdata:AutoIncrement="true"
                                msdata:AutoIncrementSeed="1" type="xs:int" />
                                                <xs:element name="datetime" type="xs:dateTime"
                                minOccurs="0" />
                                                <xs:element name="author" type="xs:string"
                                minOccurs="0" />
                                                <xs:element name="subject" type="xs:string"
                                minOccurs="0" />
                                                <xs:element name="comments" type="xs:string"
                                minOccurs="0" />
                                          </xs:sequence>
                                    </xs:complexType>
                              </xs:element>
                        </xs:choice>
                  </xs:complexType>
                  <xs:unique name="Constraint1" msdata:PrimaryKey="true">
                        <xs:selector xpath=".//guestbook" />
                        <xs:field xpath="id" />
                  </xs:unique>
            </xs:element>
      </xs:schema>
      <guestbook>
            <id>1</id>
      </guestbook>
</NewDataSet>
0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 200 total points
ID: 23625112
You need at least one guestbook element inside your NewDataSet.
Normally you don't include the schema in the XML, but you reference it
(but some applications do allow inclusion of the schema)

Your XML should look like this

<NewDataSet>
<!-- maybe the schema goes here -->
 <guestbook>
    <id>1</id>
    <datetime>2008-05-08T12:23:45</datetime>
    <author>me</author>
    <subject>about me</subject>
    <comments>no comments</comments>
 </guestbook>
</NewDataSet>
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 23625122
had the question open during dinner,
too late in the show :-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Author Comment

by:Starr Duskk
ID: 23628383
I tried both, now I'm getting the error:
 
Value cannot be null. Parameter name: url
It is in this function:
    Sub PopulateDataSet()
        myDataSet = New DataSet()
        myDataSet.ReadXml(strFilePath, XmlReadMode.ReadSchema)
    End Sub
on this line:
 myDataSet.ReadXml(strFilePath, XmlReadMode.ReadSchema)
 
I'm not understanding how it is finding my dataset anyway. In his code, there is no reference to "NewDataSet" anywhere.
What directory do I put the .xsd file in? I have it in app_code/xmlSchemas.
thanks.
 
0
 
LVL 7

Assisted Solution

by:skvikram
skvikram earned 400 total points
ID: 23657423
myDataSet.ReadXml(server.mappath(strFilePath), XmlReadMode.ReadSchema)
This will bind to the root element of the xml which is NewDataSet in your case.
 
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 23663102
The strFilePath already has the servermappath previously set.
 strFilePath = Server.MapPath("guestbook.xml")
 
0
 
LVL 7

Assisted Solution

by:skvikram
skvikram earned 400 total points
ID: 23721301

strFilePath = Server.MapPath("~\guestbook.xml")
or

strFilePath = Server.MapPath("~guestbook.xml")
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 23724077
Okay, I'm going to close this out and start a new ticket. I'm getting more errors. But different.
thanks!
 
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question