XmlDocument and iso-8859-1 Encoding

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mogens Nielsen - Elbek & Vejrup A/S (MogensNielsenElbekVejrupAS_at_discussions.microsoft.com)
Date: 02/15/05


Date: Tue, 15 Feb 2005 02:27:02 -0800

Hi all,
I have an application loading xml-documents. The purpose is just to load the
document and do some processing. The documents is generated by external
vendors outside my company.
Some of the vendors, however, delivers the documents encoded as iso-8859-1 -
the document root looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
...

In my application which is written in C# I use the following code to load
the document:
XmlDocument xmlInvoiceDocument = new XmlDocument();
xmlInvoiceDocument.Load(filename);

When the file is UTF-8-encoded this works perfectly, but when loading a
iso-8859-1 document it throws an XmlException with the message: "The data at
the root level is invalid. Line 1, position 44.".

Do I have any options in changing the encoding of the XmlDocument-object
before loading(I think the exception is caused by .NET not knowing the fact
that the file is iso-8859-1 encoded) ??

Does anyone have a clue ?

Thanks in advance,
Mogens Nielsen
Elbek & Vejrup A/S



Relevant Pages

  • Re: Pacific Pinball Expo call out to volunteers!
    ... vendors and more games this year which means we need more help! ... the expo aroung 1:00pm I can help out with the load in. ... Monday or Tues to qualify for a weekend pass. ...
    (rec.games.pinball)
  • Re: [fw-wiz] dual ISP connections
    ... hassle that is really not necessary these days, ... by several vendors that handle this type of high availability / load ...
    (Firewall-Wizards)