ID:               30920
 User updated by:  hieu at laposte dot net
 Reported By:      hieu at laposte dot net
 Status:           Bogus
 Bug Type:         XML related
 Operating System: windows xp
 PHP Version:      5.0.2
 New Comment:

print_r doesn't work correctly with simplexml, okay... but please read
this new code, it doesn't use print_r and shows the same bug :

bug.xsd =
<?xml version="1.0" encoding="utf-16" ?>
<xs:schema id="bug" xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <xs:element name="dataset">
  </xs:element>
</xs:schema>

$xml = simplexml_load_file("bug.xsd");
$elt = $xml->element;
$attr = (string) $elt['name'];
echo $attr;

=> nothing is printed...
if i remove the "xs:" prefix in the xsd file, this same code displays :
"dataset"


Previous Comments:
------------------------------------------------------------------------

[2004-11-28 12:07:14] [EMAIL PROTECTED]

print_r and var_dump don't work reliably on simplexml objects... do
*not* use them or even rely on them...

And see http://www.zend.com/php5/articles/php5-simplexml.php for more
info about SimpleXML and Namespaces

------------------------------------------------------------------------

[2004-11-27 17:55:59] hieu at laposte dot net

Description:
------------
When the xml file contains this "xs:" prefix, the file is not correctly
parsed.


Reproduce code:
---------------
The XML file is :
<?xml version="1.0" encoding="utf-16" ?>
<xs:schema id="ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="ds" msdata:IsDataSet="true"; msdata:Locale="fr-FR";>
    <complexType>
    ...

  </xs:element>
</xs:schema>

Php 5 code :
$oXml = simplexml_load_file($sFileName);
print_r($oXml->element);
// doesn't work, nothing printed...

PS : this code works correctly :
$oXml = simplexml_load_file($sFileName);
$aXml = get_object_vars($oXml);
print_r($aXml['element']);
// ok i can now access the "element".


Expected result:
----------------
SimpleXMLElement Object
(
    [complexType] => SimpleXMLElement Object
        (
         .....
        )
)

Actual result:
--------------
SimpleXMLElement Object
(
)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30920&edit=1

Reply via email to