XML Root Element is missing

Posted on 2009-02-24
Last Modified: 2012-05-06
I am looking at this tutorial:

I get this error:
Exception Details: System.Xml.XmlException: Root element is missing.

Line 62:     Sub PopulateDataSet()
Line 63:         myDataSet = New DataSet()
Line 64:         myDataSet.ReadXml(strFilePath, XmlReadMode.ReadSchema)
Line 65:     End Sub

Source: \Guestbook\Guestbook.aspx.vb    Line: 64

The guestbook.xml file only has this in it right now:
<?xml version="1.0" encoding="utf-8" ?>

What do I need?


Question by:BobCSD
    LVL 26

    Expert Comment

    by:Anurag Thakur
    if the line mentioned by u is there then the exception will definitely come as its not a valid xml

    add at least the basic of you xml
    or something which can be loaded and treated as xml
    LVL 27

    Expert Comment

    Please post your xml and we have a look at it.
    LVL 1

    Author Comment

    LVL 26

    Accepted Solution

    did you read my comment

    you mentioned
    The guestbook.xml file only has this in it right now:
    <?xml version="1.0" encoding="utf-8" ?>

    if the xml file contains this only then the exception you are getting is correct
    where is the root element

    how can you load the xml file to you object by using the following line
    myDataSet.ReadXml(strFilePath, XmlReadMode.ReadSchema)
    LVL 39

    Assisted Solution

    If you change

    <?xml version="1.0" encoding="utf-8" ?>

    in your xml file into:

    <?xml version="1.0" encoding="utf-8" ?>
     <test />

    you will not get an error anymore (well, you will probably get another error then, about the xml not being compliant with the schema).
    LVL 1

    Author Comment

    I gave up on this so will close it out.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now