Parsing error opening XML file?!?!

  • Thread starter Thread starter Jack Black
  • Start date Start date
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
 
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?
 
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
 
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
 
Back
Top