简体   繁体   中英

Remove XML declaration using msxml2 IXMLDOMDocument2

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

<? some text ?> <? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM