note 110485 added to simplexmlelement.asxml
| From: | andreas dot theissen at t-online dot de | Date: | Sat, 27 Oct 2012 12:37:12 +0000 |
| Subject: | note 110485 added to simplexmlelement.asxml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191559@lists.php.net to get a copy of this message | ||
To prevent asXML from encoding vowels unwantedly, simply use an approriate XML header with encoding
in advance.
If you do so, asXML will happily leave your vowels (and the header) entirely untouched.
<?php
$xmlstr =
'<?xml version="1.0" encoding="UTF-8"?>
<keys>
<key lang="en"><Insert></key>
<key lang="de"><Einfügen></key>
</keys>';
$sxe = new SimpleXMLElement($xmlstr);
$output = $sxe->asXML();
?>
$xmlstr and $output are identical now.
The subsequent use of html_entity_decode() (as proposed in the very beginning in another post) has
several drawbacks:
1. It is slow
2. It is expensive
3. If there are already encoded arrow brackets or double quotes in your source for instance (as
shown in the above example), markup will be broken.
----
Server IP: 212.124.37.9
Probable Submitter: 80.143.73.237
----
Manual Page -- http://www.php.net/manual/en/simplexmlelement.asxml.php
Edit -- https://master.php.net/note/edit/110485
Del: integrated -- https://master.php.net/note/delete/110485/integrated
Del: useless -- https://master.php.net/note/delete/110485/useless
Del: bad code -- https://master.php.net/note/delete/110485/bad+code
Del: spam -- https://master.php.net/note/delete/110485/spam
Del: non-english -- https://master.php.net/note/delete/110485/non-english
Del: in docs -- https://master.php.net/note/delete/110485/in+docs
Del: other reasons-- https://master.php.net/note/delete/110485
Reject -- https://master.php.net/note/reject/110485
Search -- https://master.php.net/manage/user-notes.php