Problem with XmlDocument

  • Thread starter Thread starter NN
  • Start date Start date
N

NN

Before that nothing I want to ask for excuses for my english level.

The problem that I have is the following one:

I have a file xml with "encoding=ISO-8859-1" and accents.

When in VB.NET, in a Form I write:

Dim objxml as new XmlDocument

and then when de Forms load:

objxml.Load("C\....")

The debugger gives me the following error:

"A first chance exception of type 'System.ArgumentsException' occurred in
mscorlib.dll"

"Additional information: Not valid byte in the index byte 1143"

1143 is where the accent is.

Someone can help me?
 
Hello, NN!

N> The problem that I have is the following one:

N> I have a file xml with "encoding=ISO-8859-1" and accents.

N> When in VB.NET, in a Form I write:

N> Dim objxml as new XmlDocument

N> and then when de Forms load:

N> objxml.Load("C\....")

N> The debugger gives me the following error:

N> "A first chance exception of type 'System.ArgumentsException' occurred
N> in mscorlib.dll"

N> "Additional information: Not valid byte in the index byte 1143"

N> 1143 is where the accent is.

Are you sure that xml indeed has the encoding you specified?

You can try to preconvert it first.
string xml = Encoding.GetEncoding("ISO-8859-1").GetString(File.ReadAllBytes("c:\...."));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
You might want to escape the accent symbol or replace it with a special
entity

( Example, & becomes & )
 
Back
Top