#38354 [Opn->Ver]: Unwanted reformatting of XML when using AsXML
| From: | tony2001@php.net | Date: | Sun, 06 Aug 2006 13:28:42 +0000 |
| Subject: | #38354 [Opn->Ver]: Unwanted reformatting of XML when using AsXML | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-100420@lists.php.net to get a copy of this message | ||
ID: 38354
Updated by: tony2001@php.net
Reported By: rowanjl at gmail dot com
-Status: Open
+Status: Verified
Bug Type: SimpleXML related
Operating System: Linux
PHP Version: 5.1.4
Previous Comments:
------------------------------------------------------------------------
[2006-08-06 11:39:50] rowanjl at gmail dot com
The expected and actual results are reversed, I'd correct that if I
could, sorry for the mix up.
------------------------------------------------------------------------
[2006-08-06 08:47:42] rowanjl at gmail dot com
Description:
------------
When using AsXML on an element which contains children, the returned
source is different from the original XML source. This prevents any
direct comparison between the two.
Reproduce code:
---------------
<?php
Header("Content-type: text/plain");
$XML = SimpleXML_Load_String('<code>
<a href="javascript:alert(\'1\');"><strong>Item
Two</strong></a>
</code>');
foreach ($XML->XPath("//*") as $Element) {
echo Trim($Element->AsXML()), "\n--------------------\n";
}
?>
Expected result:
----------------
<?xml version="1.0"?>
<code>
<a href="javascript:alert('1');"><strong>Item
Two</strong></a>
</code>
--------------------
<a href="javascript:alert('1');">
<strong>Item Two</strong>
</a>
--------------------
<strong>Item Two</strong>
--------------------
Actual result:
--------------
<?xml version="1.0"?>
<code>
<a href="javascript:alert('1');"><strong>Item
Two</strong></a>
</code>
--------------------
<a href="javascript:alert('1');"><strong>Item
Two</strong></a>
--------------------
<strong>Item Two</strong>
--------------------
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38354&edit=1