VB.Net XML Exception Opening document. Data at the root level is invalid. Line 1, position 1.

I'm new to XML and looking to pull the data from an XML document and put it into a SQL database.

When I try and open the document, i get an XMLException: {"Data at the root level is invalid. Line 1, position 1."}

The first line of the XML document I'm trying to read is:
  <?xml version="1.0" encoding="UTF-8" ?>

Because I'm new to XML, I'm not sure why this would be an issue.  Deleting lines down to the actual data still gives the same error (Hey, it was worth a try!)

I can open the file with an XML reader (if ProhibitDTD is set to false), but then parsing through the data seems to be a chore.

Any suggestions?  Any and all advice would be much appreciated!  Thanks in advance...
genehayesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

genehayesAuthor Commented:
Ok, realized more info on this might be helpful...  Sorry!

I'm using VB.Net 2005 and trying to open the XML with:

       Dim reader As New Xml.XmlDataDocument
       reader.LoadXml("C:\test.xml")

Using XMLDocument doesnt work either.  Same error message.
0
PaulHewsCommented:
There should not be any space before the declaration tag.

If you are using XMLDocument, use Load and not LoadXML to load an URL or file.
0
PaulHewsCommented:
>reader.LoadXml("C:\test.xml")

There's your problem... Use

reader.Load("C:\test.xml")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
genehayesAuthor Commented:
Thanks!  Seems so simple, but I wasn't getting it.

Stay tuned, probably more XML questions coming!

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.