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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 19:01:29 2024 UTC