Search code examples
phpsimplexmliconv

Iconv, posted data and simpleXML


So I am using simplexml_load_string on some posted XML. However I get the below error.

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 8: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xA3 0x37 0x30 0x30 in map_view.php on line 7

The page is encoded in UTF8. I think it may be the pound sign? I would iconv it yet dont know the current encoding.

<?xml version="1.0" encoding="utf-8"?>
<documentContent>
  <property>
    <pic1 hiresURL="http://dmqa.briefyourmarket.com/management/house-sample.jpg" imgpath="http://dmqa.briefyourmarket.com/management/house-sample.jpg" />
    <postCode>de560db</postCode>
    <address>Chilly Road, Bingley, Oxon, OX17</address>
    <postcode>OX17 2HE</postcode>
    <price>£700,000</price>
  </property>
</documentContent>

Solution

  • Pound sign is 0xC2 0xA3 in UTF-8; the bytes reported in the error message are the ISO-8859-1 characters: £700, so I think your document is in fact encoded as ISO-8859-1 despite the declaration which indicates UTF-8.