xml - Load XMLDocument from byte array (optionally containing BOM characters) -
I've seen many posts here, so why about loading XML documents from some data sources, where data in Microsoft Proprietary UTF-8 is preamble (for example,).
However, I can not find an elegant (and work!) Solution that does not involve pushing BOM characters manually.
For example, P>
byte [] b = system. IO.File.ReadAllBytes ("c: \\ temp_file_containing_bom.txt"); (System.IO.MemoryStream oByteStream = new System.IO.MemoryStream (b)) {{System.Xml.XmlTextReader oRD = New System.Xml.XmlTextReader (oByteStream)) using {System.Xml.XmlDocument oDoc = new System Xml.XmlDocument (); ODoc.Load (ORD); Console.WriteLine (oDoc.OuterXml); Console.ReadLine (); }}
... but it is still throwing "illegal data" exception.
My problem is that I have a large byte array sometimes in BOM and sometimes it does not have to be loaded into XMLDocument. And I do not believe I want to take care of that "helper" byte.
that BOM is no longer 'ownership'. This XML spec has been written in Java only (1.4) It has a problem in the old version. If you have a MS technology explosion then it is very humorous.
If the BOM is not the first letter of the sequence, then first use a buffer input stream to filter the BOM by pressing the character back.
Comments
Post a Comment