all groups > dotnet xml > march 2005 >
You're in the

dotnet xml

group:

XML Encoding question (C#)


XML Encoding question (C#) Mike
3/21/2005 4:49:03 PM
dotnet xml:
Hi! I have the following problem:

I am getting an XML file from a 3rd party. The encoding on the XML file is
encoding="utf-8"

I have no control over generation of this file. This file is produced by a
Lotus Notes system and often has illegal characters embedded to it. Of course
the .NET XML parser produces an error.

I’ve been reading about XmlConvert.EncodeName but not sure where to apply
it. It seems to me that I can call this method once the doc has been loaded
into DOM?
But it breaks before I load the doc into DOM.

Here’s how I load the xml file:

private static XmlDocument _xmlDocument = null;

public static XmlDocument LoadAndReturnXmlDocument(string pstrInputFile)
{
_xmlDocument = new XmlDocument();
_xmlDocument.PreserveWhitespace = false;
_xmlDocument.Load(pstrInputFile);
_xmlDocument.
return _xmlDocument;
}

What would you recommend I do to fix this problem?

Any input is greatly appreciated.

Re: XML Encoding question (C#) Oleg Tkachenko [MVP]
3/22/2005 1:25:50 PM
[quoted text, click to view]

The recommended way is to fix broken software in the first place.
Otherwise you can try to fix XML produced using non-XML tools, such regexp.


--
Oleg Tkachenko [XML MVP, MCP]
Re: XML Encoding question (C#) Ion Vasilian
3/22/2005 2:56:44 PM
Hi,

In your sample code you meant to write:
[quoted text, click to view]
Right? XmlDocument.Load(string filename) assumes that the input is just a
url,
not the data itself.

Ion

[quoted text, click to view]

AddThis Social Bookmark Button