Hi, I already checked existing responses on the forum and on internet but I failed to read CDATA in xml file. Could you tell me how to read a large CDATA inside an xml document into BigText?
Example xml:
<response>
<item key="12345">
<content><![CDATA[<p>1024+ characters here......</p>]]>
<item>
</response>
I tried:
CData2 := XMLDoc2.createCDATASection(XMLElement2.selectSingleNode('content').text); but it errors out "the length of the text string exceeds the size of the string buffer" .
Once I have the text in CDATA, I can use CData2.substringData function to move forward.
Thanks in advance.
0
Answers
ContentNode3 is 'Microsoft XML, v6.0'.IXMLDOMText
ReadCount2 as int
TextToAdd2 as Text1024
ContentNode3 := XMLNode2.selectSingleNode('content').firstChild();
CLEAR(BigText2);
ReadCount2 := (ContentNode3.length DIV 1024) + 1;
FOR Counter3 := 1 TO ReadCount2 DO BEGIN
TextToAdd2 := ContentNode3.substringData((Counter3-1)*1024,1024);
BigText2.ADDTEXT(TextToAdd2);
END;
It's important to know how many "readcount2" is out there and use a loop because if the content has 1000 characters only, then ContentNode3.substringData(1025,1024) creates an error message because there is no text to read.