HTML tags in XML

Ken Ray kray at sonsothunder.com
Tue Mar 21 13:30:31 EST 2006


On 3/21/06 11:51 AM, "Trevor DeVore" <lists at mangomultimedia.com> wrote:

> On Mar 21, 2006, at 9:41 AM, Ken Ray wrote:
> 
>>  My XML Library handles getting and setting CDATA information for a
>> node quite
>> easily
> 
> Ken,
> 
> This is good to know.  The RevXML external doesn't handle CDATA, does
> it?  I seem to recall that when I tested using CDATA with RevXML it
> didn't work which is kind of a bummer.

Actually, you can *retrieve* CDATA with revXMLNodeContents, but you can't
*set* it. That's part of the reason I'm still updating my XML Library. ;-)

Here's an example:

Contents of Field 1:
----------------------
<?xml version="1.0"?>
<root>
    <test>
      <![CDATA[<b>This is a test</b>]]>
    </test>
</root>

put fld 1 into tXML
put revCreateXMLTree(tXML,true,true) into tID
put revXMLNodeContents(tID,"/root/test")

RETURNS:
   <b>This is a test</b>

put revXMLText(tID)

RETURNS:
  <?xml version="1.0"?>
  <root><test><![CDATA[<b>This is a test</b>]]></test></root>


Now, we try to set the data:

revPutIntoXMLNode tID,"/root/test","<b>This is another test</b>"
put revXMLText(tID)

RETURNS:
  <?xml version="1.0"?>
  <root><test><b>This is another test</b></test></root>


Trying it with CDATA tags already around it:

revPutIntoXMLNode tID,"/root/test","<![CDATA[<b>This is another test</b>]]>"
put revXMLText(tID)

RETURNS:
  <?xml version="1.0"?>
  <root><test><![CDATA[<b>This is another
test</b>]]></test></root>

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the use-livecode mailing list