Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

C++ DOM object load() method: how to handle text mode files (with EOF character ^Z)

$
0
0

The load() method of an IXMLDOMDocumentPtr object fails reading an XML text file containing an explicit end-of-file character (^Z). This could happen if the file was copied using "copy /a src.xml result.xml". When reading "result.xml", the load() method will fail with the following error:

 An invalid character was found in text content.

It's possible to avoid this problem by opening the file in text mode (e.g. using fopen(..., "rt")), reading the file's content into a buffer, and use the loadXML() method on this buffer, but I'd prefer to avoid the memory allocation.

  • Is there a way to specify text mode (instead of binary mode) for the load() method?
  • Is it possible to open a file stream from the program (e.g. FILE* or std::istream) and let the XML parser use the right functions for reading text from that stream?


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>