Hi,
I'm having a problem with SimpleXML. When I'm using the children() method to get the contents of an XML element, with elements that contain HTML, it will parse the HTML contents as XML. How would I make it so that it won't parse HTML?
Hi,
I'm having a problem with SimpleXML. When I'm using the children() method to get the contents of an XML element, with elements that contain HTML, it will parse the HTML contents as XML. How would I make it so that it won't parse HTML?
The example you posted is valid XML, but the <div>
and <img>
-tags are part of the XML document.
Basically, you have to use CDATA (see natriums answer), or escape the HTML entities in the XML.
Hi!
I tried CDATA, but this doens't work. Could you just give me an real example of use, to see if I am right with my one?
Thank you in advance. b1
CDATA worked with me! =D
<?xml version="1.0" encoding="UTF-8"?>
<destaques>
<destaque imagem="cartoes.jpg">
<![CDATA[
Text with <em>some</em> HTML.
]]>
</destaque>
<destaque imagem="banner2.jpg" />
<destaque imagem="delivery.jpg" />
</destaques>