Formatting in XML?

Ken Ray kray at sonsothunder.com
Sat Feb 5 00:38:09 CST 2005


On 2/5/05 12:19 AM, "Terry Vogelaar   (de Mare)" <tvogelaar at de-mare.nl>
wrote:

>> <Card>
>      <Header>This fantastic card</Header>
>      <Content>
>          <Red>This</Red> needs to be displayed <italic>formatted</italic>
>          just like <bold>HTML</bold>; it should be in
> <italic>one</italic> field.
>      </Content>
> </Card>
> 
> If I try revXMLNodeContents(id,"/Card/Content"), the function returns
> empty. No "xmlerr", not even " needs to be displayed just like ; it
> should be in field." Not that I want any of those...
> 
> How do I get what I want?

Terry, the problem is that you have tags within tags... the <Red> tag is a
node just like <Content>. What you need is a CDATA tag that will let you
store formatted data inside of a node, like:

<Content>
  <![CDATA[<Red>This</Red> needs to be displayed <italic>formatted</italic>
just like <bold>HTML</bold>; it should be in <italic>one</italic> field.]]>
</Content>

Any data inside the <![CDATA[ ... ]]> structure is not parsed by the
interpreter; it's kind of like HTML's <pre> tag.  you can use the
'revXMLNodeContents' to retrieve the CDATA tag, so:

  put revXMLNodeContents(id,"/Content")

for my chunk above would return:

  <Red>This</Red> needs to be displayed <italic>formatted</italic> just
  like <bold>HTML</bold>; it should be in <italic>one</italic> field.

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