I searched in this site there were lots of answers but none of them are working for me. I am trying to parse the below XML using PHP simplexml_load_string.
My XML is:
<?xml version="1.0" encoding="utf-8"?>
<address>
<name>Peter</name>
<country>Großbritannien</country>
</address>
When I print it using print_r the result is showing as below:
SimpleXMLElement Object
(
[name] => Peter
[country] => Großbritannien
)
and when I use ini_set('default_charset', 'UTF-8') or header('Content-Type: text/html; charset=utf-8') the result is:
SimpleXMLElement Object
(
[name] => Peter
[country] => Großbritannien
)
But When I try to insert the country value using PHP (with the header set as utf8) in the database (MySQL) then its inserting as Großbritannien. My tables character-set is UTF8 and collation of the column is utf8_unicode_ci. However when I directly insert the country value into the table(using phpMyAdmin or terminal) then its inserting properly.
I would like to know why the country value is not inserting properly from my PHP parsing page.
My PHP sample code is below:
$notificationXml = simplexml_load_string($xml);
$con = $notificationXml->country;
mysql_query("INSERT INTO test_1 (con) values ('$con')");
Please help me out. Thanking you all in advance.