Formatting in XML?

Terry Vogelaar (de Mare) tvogelaar at de-mare.nl
Sat Feb 5 10:23:11 EST 2005


Op 5-feb-05 om 7:38 heeft Ken Ray het volgende geschreven:

> 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.

Thanks, Ken, that was very helpful.

Of course I actually wanted to have "This" displayed in red instead of 
between visible tags. But I can replace the <bold> with <b> etc to have 
normal HTML tags, so I can set the HTMLtext of the field to the content 
of 'Content'.

Next question:
How do I set the content of a node to the <![CDATA[ ... ]]> structure? 
In my attempts it replaces the < and > to < and >. Should I just 
use the 'replace' function or is there a smarter way?

Terry



More information about the use-livecode mailing list