使用PHP中的SimpleXML在XML中访问HTML

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?

did you try to use CDATA ?

<xml>
    <node>
        <![CDATA[
        <div>
            <img src="..." />
        </div>
        ]]>
    </node>
</xml>

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.

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>