• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1750
  • Last Modified:

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 Duskk
Starr Duskk
2 Solutions
Anurag ThakurCommented:
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.
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Anurag ThakurCommented:
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)
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.

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now