Question

I want to remove XML declaration only from an XML using C++

<?xml version="1.0" encoding="UTF-8" ?>

Then I want to add this line and resave the XML

<?xml version="1.0" encoding="ISO-8859-1" ?>

All I have and know how to do it load the xml document

hr = IXMLDOMDocument->load(vstrfilename, &status);

using the IXMLDOMDocument2 interface of msxml2

How can I achieve this ? My programming environment is borland c++ builder 6

Thank You

Was it helpful?

Solution

<? some text ?> is a processing instruction. The node is of type NODE_PROCESSING_INSTRUCTION.

Retrieve the node as the first child of the document, using get_childNodes and delete it with removeChild.

Then, use createProcessingInstruction for the new encoding and use insertBefore (with the new first child) to add it to the document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top