Tech Tip: How to get CDATA values from XML elements
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: November 18, 2004
In 4D 2003, when XML processing commands were introduced, it was only possible to read the text value of an element. For example,
<element>Text Value</element>
CDATA sections, however, could not be processed.
<element>Text Value
<![CDATA[CDATA value]]>
</element>
In 4D 2004, the command DOM GET XML ELEMENT VALUE has been modified to allow the user to pass in an optional third parameter that will process those CDATA sections. Supposing the XML sample above is saved in a file called "my.xml", the following commands will parse it:
$root:=DOM Parse XML source("my.xml")
DOM GET XML ELEMENT VALUE($root;$value;$cdata)
Now $value contains "Text Value" while $cdata contains "CDATA value"