I have a simple XML with a CDATA section like:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<config>
<input>
<![CDATA[
line
another line
and another
]]>
</input>
...
</config>
And I have the current code for parsing the CDATA section using MSXML.
for (int i = 0, count = pChildNodes->Getlength(); i < count; ++i) {
IXMLDOMNodePtr pNode = pChildNodes->Getitem(i);
if (pNode->GetnodeType() != NODE_COMMENT && pNode->GetnodeType() != NODE_TEXT) {
if (pNode->GetnodeType() == NODE_CDATA_SECTION) {
IXMLDOMCDATASectionPtr pCData = pNode;
_bstr_t a = pCData->Getdata();
_variant_t b = pCData->GetnodeValue();
_bstr_t c = pCData->Gettext();
_bstr_t d = pCData->Getxml();
But none of the a
, b
, c
or d
keeps the line breaks that are in the XML. And this is the output:
lineanother lineand another
When I create the document I set the preserve white space flag:
m_pXmlDoc->put_preserveWhiteSpace(VARIANT_TRUE);
Do you have any ideas on how can I get the value of the CDATA section considering the line breaks?