XML Root Element is missing

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?


Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?
Anurag ThakurConnect With a Mentor Technical ManagerCommented:
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)
Anurag ThakurTechnical ManagerCommented:
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
Please post your xml and we have a look at it.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
abelConnect With a Mentor Commented:
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).
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I gave up on this so will close it out.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.