Connecting Tech Pros Worldwide Forums | Help | Site Map

html in xml, php & flash

Rebecca Tsukalas
Guest
 
Posts: n/a
#1: Sep 17 '06
hello,

is there an official or a correct way for the following problem:

in my xml file, there is also html text. this xml file is used in flash and a php code.
the problem is, that - using simplexml in php - the html-tags are interpreted as xml-tags and it gets difficult to use the content. if i use &gt and &lt instead of < and or place the html-text in a CDATA, flash doesnt display the text as html and also returns errors. is it common at all, to place html into an xml-file?

a simple example of the xml-file:
----------------------------------
<?xml version='1.0' encoding='utf-8'?
<website
<site title="Titel"
<text><p>lalala <b>tada</b<font color="#ff0000">dings
</font></pand a <a href="blabla.html" target="_blank"
link</a><img src="bild.jpg"/></text
</site
</website
----------------------------------

i already have some methods of resolution to solve the problem:
- modify the html tags in the php code, so simplexml does not recognize them as xml-tags
- replace/delete the &lt and &gt or cdata by string operator in flash
- code own php script to put the xml into a php array

the point is that i want to do it correctly, use a "clean" (and perhaps not pedestrian) way so i will not have any unconsidered problems afterwards. perhaps you could suggest how to do it best - it would be great, thank you!

Colin McKinnon
Guest
 
Posts: n/a
#2: Sep 17 '06

re: html in xml, php & flash


Rebecca Tsukalas wrote:
Quote:
>
i already have some methods of resolution to solve the problem:
- modify the html tags in the php code, so simplexml does not recognize
them as xml-tags - replace/delete the &lt and &gt or cdata by string
operator in flash - code own php script to put the xml into a php array
>
I guess the question is really this: Is the HTML always atomic wrt the XML -
in which case it doesn't matter.

The CDATA thing will work as long as you don't have CDATA encolsures within
your html. Personally, I would go for base64 encoding the html and
including the encoding mechanism in the markup - that should be less of an
overhead than the string replace method and (IIRC) the HTML can be
reconstructred by XSLT.

Of course, if you're HTML is not atomic with regard to the XML, then you've
got quite a different problem.

HTH

C.

Closed Thread