|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38354 Unwanted reformatting of XML when using AsXML
Submitted: 2006-08-06 08:47 UTC Modified: 2006-08-06 19:40 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rowanjl at gmail dot com Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rowanjl at gmail dot com
New email:
PHP Version: OS:


 [2006-08-06 08:47 UTC] rowanjl at gmail dot com
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:
	Header("Content-type: text/plain");
	$XML = SimpleXML_Load_String('<code>
	<a href="javascript:alert(\'1\');"><strong>Item Two</strong></a>
	foreach ($XML->XPath("//*") as $Element) {
		echo Trim($Element->AsXML()), "\n--------------------\n";

Expected result:
<?xml version="1.0"?>
	<a href="javascript:alert('1');"><strong>Item Two</strong></a>
<a href="javascript:alert('1');">
  <strong>Item Two</strong>
<strong>Item Two</strong>

Actual result:
<?xml version="1.0"?>
	<a href="javascript:alert('1');"><strong>Item Two</strong></a>
<a href="javascript:alert('1');"><strong>Item Two</strong></a>
<strong>Item Two</strong>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-06 11:39 UTC] 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 19:40 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Fixed in HEAD and PHP_5_2 branch
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 11:01:32 2024 UTC