« Return to Thread: Sending XML containing html tags

Re: Sending XML containing html tags

by Julio Carneiro :: Rate this Message:

Reply to Author | View in Thread

Rafael,
That is exactly what it is supposed to do.
XML has very strict rules about the characters that can be used for  
element names and element values.
Some characters albeit not permitted inside element values can be  
translated into character encoded sequences (<, >, &).
Other are not even allowed: accented chars for example.
XML does provide a mean to send element values that contain invalid  
characters unencoded. That is done via a CDATA element value.

In 4D you do that by adding a '*' as a 3rd parameter to DOM SET  
ELEMENT VALUE, as in:
> DOM SET XML ELEMENT VALUE($elem;$answer;*)

Javascript xml tools handle CDATA sections properly and you should not  
have to do anything special on AJAX side.
Adding the '*' as above should do the trick.

hth
julio

On May 13, 2008, at 12:34 PM, Rafael Escote wrote:

> Dear folks, i'm trying to build a correct AJAX (using RICO js libs)
> response from 4D, so i'm building an
> XML document using the DOM commands and sending it via
> SEND HTML BLOB.
> However I've found that if the response text includes
> some tags to format the html page
> the result is not the one desired. For example:
>
> // Test response
> $answer:="<span>Testing</span>"
>
> $myxml:=DOM Create XML Ref("ajax-response")
>
> DOM SET XML OPTIONS($myxml;"ISO-8859-1")
>
> $elem:=DOM Create XML element($myxml;"/ajax-response/
> response";"type";"element";"id";"myObject")
>
> DOM SET XML ELEMENT VALUE($elem;$answer)
> DOM EXPORT TO VAR($myxml;$result)
> DOM CLOSE XML($myxml)
> ...
> SEND HTML BLOB($result;"text/xml")
>
> The sent text is always translating the tag <span> into
> somthing like:
> <span>Pepe</span>
>
> Being an XML, BLOB ignorant I'm not sure what i'm doing wrong...
> Any help?
> TIA
> --
> Rafael Escoté
> BlauSoft s.l.
>

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

 « Return to Thread: Sending XML containing html tags