php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jesse at eonstreet dot com
New email:
PHP Version: OS:

 

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

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="http://www.w3.org/2001/XMLSchema-instance" ><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] => http://www.w3.org/2001/XMLSchema-instance )
Tag: node Atrributes: Array ( [xsi:type] => Test ) 

Actual result:
--------------
Node XSI:TYPE = 
Tag: root Atrributes: Array ( [xmlns:xsi] => http://www.w3.org/2001/XMLSchema-instance )
Tag: node Atrributes: Array ( [xsi:type] => Test ) 

Patches

Pull Requests

History

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

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: Tue Oct 15 16:01:28 2024 UTC