We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

XML: incomplete content error

Starr Duskk
Starr Duskk asked
on
Medium Priority
758 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

Comment
Watch Question

Technical Architect
Commented:
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>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
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>
Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
had the question open during dinner,
too late in the show :-)
Starr DuskkASP.NET VB.NET Developer

Author

Commented:
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.
 
Commented:
myDataSet.ReadXml(server.mappath(strFilePath), XmlReadMode.ReadSchema)
This will bind to the root element of the xml which is NewDataSet in your case.
 
Starr DuskkASP.NET VB.NET Developer

Author

Commented:
The strFilePath already has the servermappath previously set.
 strFilePath = Server.MapPath("guestbook.xml")
 
Commented:

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

strFilePath = Server.MapPath("~guestbook.xml")
Starr DuskkASP.NET VB.NET Developer

Author

Commented:
Okay, I'm going to close this out and start a new ticket. I'm getting more errors. But different.
thanks!
 
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.