From: norbert_schuetz at bigfoot dot com
Operating system: Linux 2.6.18-5-686
PHP version: 5.2.6
PHP Bug Type: SimpleXML related
Bug description: SimpleXMLElement doesn't read attributes if xml nodes has a
value
Description:
------------
PHP Version: PHP 5.2.0-8+etch11 (CLI) from
php5-cli_5.2.0-8+etch10_i386.deb
Linux 2.6.18-5-686 #1 SMP Sun Aug 12 21:57:02 UTC 2007 i686 GNU/Linux
Simplexml support => enabled
Revision => $Revision: 1.151.2.22.2.15 $
Schema support => enabled
libexpat1_1.95.8-3.4_i386.deb
Description of problem:
For the second xml product item from the sample XML there is no
order_id-attribute in the resulting object, while both first an last items
have it.
Reproduce code:
---------------
<?php
$xmlstr=<<<EOXML
<?xml version='1.0' standalone='yes'?>
<products>
<product order_id="0001"></product>
<product order_id="0002">PHP book</product>
<product order_id="0003">
<name>PHP book</name>
</product>
</products>
EOXML;
$xml=new SimpleXMLElement($xmlstr);
print_r($xml);
?>
Expected result:
----------------
@attributes array for second item as well
Actual result:
--------------
SimpleXMLElement Object
(
[product] => Array
(
[0] => SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[order_id] => 0001
)
)
[1] => PHP book
[2] => SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[order_id] => 0003
)
[name] => PHP book
)
)
)
--
Edit bug report at http://bugs.php.net/?id=44973&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44973&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44973&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44973&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44973&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44973&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44973&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44973&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44973&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44973&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44973&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44973&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44973&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44973&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44973&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44973&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44973&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44973&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44973&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44973&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44973&r=mysqlcfg