Reading large CDATA from XML file into BigText

serdarulutas
Member Posts: 50
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.
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
-
XMLPort offers property TextType as BigText. You should go this way instead of use automation or DotNet assemblies.0
-
I did it this way. Imagine <content> element in the xml might hold 1024+ characters.
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions