There is no Unicode byte order mark. Cannot switch to Unicode

The reality of your file’s encoding appears to conflict with that specified by your XML declaration. If your file actually uses one-byte characters, declaring encoding=”utf-16″ won’t change it to use two-byte characters, for example. Try removing the conflicting encoding from the XML declaration. Replace <?xml version=”1.0″ encoding=”utf-16″?> with <?xml version=”1.0″?> You may also be able … Read more

DTD prohibited in xml document exception

First, some background. What is a DTD? The document you are trying to parse contains a document type declaration; if you look at the document, you will find near the beginning a sequence of characters beginning with <!DOCTYPE and ending with the corresponding >. Such a declaration allows an XML processor to validate the document … Read more

What is the best way to parse (big) XML in C# Code?

Use XmlReader to parse large XML documents. XmlReader provides fast, forward-only, non-cached access to XML data. (Forward-only means you can read the XML file from beginning to end but cannot move backwards in the file.) XmlReader uses small amounts of memory, and is equivalent to using a simple SAX reader. using (XmlReader myReader = XmlReader.Create(@”c:\data\coords.xml”)) … Read more

Deciding on when to use XmlDocument vs XmlReader

I’ve generally looked at it not from a fastest perspective, but rather from a memory utilization perspective. All of the implementations have been fast enough for the usage scenarios I’ve used them in (typical enterprise integration). However, where I’ve fallen down, and sometimes spectacularly, is not taking into account the general size of the XML … Read more

Reading Xml with XmlReader in C#

My experience of XmlReader is that it’s very easy to accidentally read too much. I know you’ve said you want to read it as quickly as possible, but have you tried using a DOM model instead? I’ve found that LINQ to XML makes XML work much much easier. If your document is particularly huge, you … Read more

tech