Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get xml children without replacing html entities in PHP

Tags:

php

xml

I have this code:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
$strXml = '
<root>
<kid><div>ABC&#8226;&#62;</div></kid>
<kid2>DEF</kid2>
</root>';   

$objXml = new SimpleXMLElement($strXml);
$arrNodes = $objXml->xpath('/root/*');
foreach($arrNodes as $objNode) {
    /* @var $objNode SimpleXMLElement */
    echo $objNode->asXML(); 
}

The code extracts the first children of the root and displays the content. The problem is the html entities are converted to characters. Is there any way the code output the initial XML content without any conversion ?

like image 920
johnlemon Avatar asked Feb 29 '12 19:02

johnlemon


1 Answers

Is there any way the code output the initial XML content without any conversion ?

No.

Aside: Why do you care? They're the same character.

like image 139
salathe Avatar answered Oct 26 '22 15:10

salathe