|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53192 SimpleXML ignores XSI:TYPE attributes
Submitted: 2010-10-28 16:01 UTC Modified: 2010-10-28 20:34 UTC
From: jesse at eonstreet dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.3.3 OS: Windows 7 64bit
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: jesse at eonstreet dot com
New email:
PHP Version: OS:


 [2010-10-28 16:01 UTC] jesse at eonstreet dot com

It seems that SimpleXML removed all references to xsi:type in every node.
XML Parser does show the xsi:type as an attribute.

The code below demonstrates this.

Test script:
$xmlData = '<root xmlns:xsi="" ><node xsi:type="Test">DATA</node></root>';

// Try First with SimpleXml
$xml = simplexml_load_string($xmlData);

echo "Node XSI:TYPE = ". (string)$xml->node['xsi:type'];

// Try using XML Parser
function tag_open($parser, $tag, $attributes) {
   if (!empty($attributes)) { echo "<br /> Tag: $tag Atrributes: ".print_r($attributes,true); }

$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($parser, "tag_open", false);
xml_parse($parser, ltrim($xmlData));

Expected result:
Node XSI:TYPE = Test
Tag: root Atrributes: Array ( [xmlns:xsi] => )
Tag: node Atrributes: Array ( [xsi:type] => Test ) 

Actual result:
Node XSI:TYPE = 
Tag: root Atrributes: Array ( [xmlns:xsi] => )
Tag: node Atrributes: Array ( [xsi:type] => Test ) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-28 20:34 UTC]
-Status: Open +Status: Bogus
 [2010-10-28 20:34 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

it works based on namespace scope so you need to tell it what namespace is in 
current scope for it to access the elements/attributes
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 14:01:29 2024 UTC