0

Possible Duplicate:
Problem with simpleXML and entity not being defined

I have this tag with an entity in an xml file:

<comune>Forli&#39;</comune>

Simple xml in php fail to parse the file:

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: parser error : Entity 'igrave' not defined

How can i do?

Community
  • 1
  • 1
Omega
  • 8,640
  • 9
  • 30
  • 29
  • 1
    That's not the line that's throwing the error. The line would have something like `ì` in it. What you posted above is 100% valid XML... – ircmaxell Apr 29 '11 at 13:35
  • Tell the author of the XML document to use the Unicode value or provide a DTD where the entity is valid. – Gordon Apr 29 '11 at 13:39

2 Answers2

1

I tried this a small example and it worked for me

XML:

<?xml version="1.0" encoding="UTF-8"?>
<comune>
<comune>Forli&#39;</comune>
</comune>

PHP:

    $xml = simplexml_load_file('test.xml');

    foreach($xml->children() as $child){ 
        echo '<pre>';
        print_r((string)$child);
        echo '</pre>asd';
    }

OUTPUT:

Forli'
jimy
  • 4,848
  • 3
  • 35
  • 52
0

Check this solution for help

Community
  • 1
  • 1
Muhammad Zeeshan
  • 8,722
  • 10
  • 45
  • 55