Set names and collation UTF8 does not works in SimpleXML or MySQL <p>I am gettin XML data which header has utf8 setted:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p>I <strong>download</strong> it using <strong>CURL</strong> and it is downloaded correctly with UTF8 chars.</p> <p>I <strong>parse</strong> that downloaded <strong>xml</strong> files using <strong>SimpleXML</strong> using this code:</p> <pre><code>&lt;?php </code></pre> <p>class XMLParser{</p> <pre><code>public function __construct(){ } public function parseFile($path){ $xml = ''; if(!is_null($path)){ $file = file_get_contents($path); if(!is_null($file)){ $xml = new SimpleXMLElement($file); } else{ echo 'there is no file'; } } else{ echo 'Wrong path!'; } return $xml; } </code></pre> <p>} ?></p> <p>And <strong>send</strong> it to <strong>database</strong> calling <strong>PDO</strong> and <strong>stored procedures</strong>, connect script has defined utf8: </p> <pre><code>$this-&gt;PDO-&gt;setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); </code></pre> <p>Each table has <strong>utf8_general_ci</strong></p> <p>But in table are chars like this:</p> <blockquote> <p>LeÃ³n de HuÃ¡nuco - Cienciano</p> </blockquote> <p><strong>UPDATE</strong>! CREATE TABLE code:</p> <pre><code>CREATE TABLE IF NOT EXISTS `jcjdkdtaur`.`fixtures` ( `Id` INT(32) NOT NULL, `UpdatedDate` varchar(100) DEFAULT NULL, `DateTime` datetime NULL DEFAULT NULL, `Date` date NULL DEFAULT NULL, `Time` time NULL DEFAULT NULL, `Status` VARCHAR(40) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL DEFAULT NULL, `League` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL DEFAULT NULL, `LeagueID` INT(11) DEFAULT NULL, `SportID` tinyint DEFAULT 1, `SportName` varchar(30) DEFAULT 'football', `Cup` varchar(20) DEFAULT NULL, `Country` VARCHAR(60) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL DEFAULT NULL, `EventName` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL DEFAULT NULL, `HomeTeam` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL DEFAULT NULL, `HomeTeam_Id` INT(11) NULL DEFAULT NULL, `AwayTeam` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL DEFAULT NULL, `AwayTeam_Id` INT(11) NULL DEFAULT NULL, PRIMARY KEY (`Id`,`HomeTeam_Id`,`AwayTeam_Id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci; </code></pre> <p>INSERT STORE PROCEDURE I CALL IT FROM PHP:</p> <pre><code>DROP PROCEDURE IF EXISTS insupd_Fixtures; DELIMITER // CREATE PROCEDURE insupd_Fixtures(IN p_id int(32), IN p_updated varchar(100), IN p_datetime datetime, IN p_date date, IN p_time time, IN p_status varchar(40),IN p_league varchar(255),IN p_leagueid int(11), IN p_sportid tinyint, IN p_sportname varchar(30), IN p_cup VARCHAR(20), IN p_country VARCHAR(60),IN p_eventname varchar(255),IN p_hometeam varchar(255),IN p_hometeam_id int(11), IN p_awayteam varchar(255),IN p_awayteam_id int(11) ) BEGIN INSERT INTO fixtures(`Id`,`UpdatedDate`,`DateTime`,`Date`,`Time`,`Status`,`League`,`LeagueID`,`SportID`,`SportName`,`Cup`,`Country`,`EventName`, `HomeTeam`,`HomeTeam_Id`,`AwayTeam`,`AwayTeam_Id`) VALUES (p_id,p_updated, p_datetime, p_date, p_time, p_status,p_league, p_leagueid, p_sportid, p_sportname, p_cup,p_country, p_eventname,p_hometeam,p_hometeam_id,p_awayteam,p_awayteam_id) ON DUPLICATE KEY UPDATE Id=p_id, UpdatedDate = p_updated, DateTime=p_datetime, Date=p_date, Time=p_time, Status=p_status, League=p_league, LeagueID = p_leagueid, SportID = p_sportid, SportName = p_sportname, Cup=p_cup, Country=p_country, EventName=p_eventname, HomeTeam=p_hometeam, HomeTeam_Id=p_hometeam_id, AwayTeam=p_awayteam, AwayTeam_Id=p_awayteam_id; END // </code></pre>