Parsing error opening XML file?!?!

J

Jack Black

Hi, all... Using VS.Net '03 (vb.net)...

I'm just entering a quick example from the KB, and getting an error right
away. Starting code below... When it hit the doc.Load line I get the error
"An Error occurred while parsing EntityName. line 4, position 28." XML File
contains all valid XML, no special characters or Unicode, etc...

Is there some trick here, or something missing from the samples (three
different samples in the KB use the same method to open an XML file)? Also
tried adding "Imports System.IO", but that didn't help...

Thanks,
Jack



' **********************************************
Imports System.XML
Imports System.Text

dim doc as XmlDocument = New XMLDocument()
doc.Load("c:\test.xml") <-- error here
 
H

Herfried K. Wagner [MVP]

Jack Black said:
I'm just entering a quick example from the KB, and getting an error right
away. Starting code below... When it hit the doc.Load line I get the
error "An Error occurred while parsing EntityName. line 4, position 28."
XML File contains all valid XML, no special characters or Unicode, etc...

Can you post your XML file or parts of it?
 
J

Jack Black

Turned out to be a friggin' ampersand... *grr* Replaced "&" with "&amp;"
and all is right with the world again... :)

On a related note, how can I get an XML write to preserve carriage
return/line feeds? Tried enabling PreserveWhitespace property, but that
didn't help...

Jack
 
J

Jay B. Harlow [MVP - Outlook]

Jack,
The "Trick" is to start with a valid XML file. You have a bad character or
two at line 4, position 28 of your XML file.

Can you post (attach) the XML file here or email it to me.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top