note 113179 added to ref.simplexml

From: Date: Mon, 09 Sep 2013 19:41:47 +0000
Subject: note 113179 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-196205@lists.php.net to get a copy of this message
Contrary to other notes posted here, SimpleXML *DOES NOT* properly handle non-UTF8 encoded XML documents. A proper "iso-8859-1" declared and encoded XML document will not parse with SimpleXML for PHP 5.2.17 or 5.5.1 when using extended characters (that is, byte values greater than 127) DOMDocument, on the other hand, will correctly parse incoming iso-8859-1 XML documents and can also be used to perform character translation to UTF8: $dom = new DOMDocument(); if($dom->loadXML($fileContents)){ // $fileContents is an XML document with iso-8859-1 encoding specified in the declaration $dom->encoding = 'utf-8'; // convert document encoding to UTF8 return $dom->saveXML(); // return valid, utf8-encoded XML ---- Server IP: 64.71.164.2 Probable Submitter: 74.4.31.242 ---- Manual Page -- http://php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/113179 Del: integrated -- https://master.php.net/note/delete/113179/integrated Del: useless -- https://master.php.net/note/delete/113179/useless Del: bad code -- https://master.php.net/note/delete/113179/bad+code Del: spam -- https://master.php.net/note/delete/113179/spam Del: non-english -- https://master.php.net/note/delete/113179/non-english Del: in docs -- https://master.php.net/note/delete/113179/in+docs Del: other reasons-- https://master.php.net/note/delete/113179 Reject -- https://master.php.net/note/reject/113179 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196205) next »