What’s going one here?
$string = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<album>
<img src="002.jpg" caption="wássup?" />
</album>
XML;
$xml = simplexml_load_string($string);
// $xmlobj = simplexml_load_file("xml.xml"); // same thing
echo "<pre>";
var_dump($xml);
echo "</pre>";
Error:
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 5: parser error : Entity ‘aacute’ not defined
áis not an XML entity – you’re thinking about HTML.Special characters are usually used “as is” in XML – an
html_entity_decode()on the input data (don’t forget to specify UTF-8 as the character set) should do the trick: