From:             php dot net at trueprices dot net
Operating system: Debian
PHP version:      5.2.5
PHP Bug Type:     SimpleXML related
Bug description:  SimpleXMLelement has no children() on element with only 
attributes?

Description:
------------
SimpleXMLelement has no children() on element with only attributes?

I try to retreive an element by xpath which goes without problems, The
child elements it contains (same namespace) are all empty element with only
attributes. However the returned SimpleXML element does not contain any
children? so i'm unable to retreive there attributes.




Reproduce code:
---------------
<?php
$data = '<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
  targetNamespace="http://www.w3.org/2001/XMLSchema";
>
<wsdl:portType name="qxqPortType">
        <wsdl:operation name="SOAP_set">
            <wsdl:input message="SetRequest"/>
            <wsdl:output message="SetResponse"/>
        </wsdl:operation>
    <wsdl:operation name="SOAP_get">
            <wsdl:input message="GetRequest"/>
            <wsdl:output message="GetResponse"/>
        </wsdl:operation>        
</wsdl:portType>
</wsdl:definitions>';

echo '<pre>';
$xml = simplexml_load_string($data);
if ($xml)
{

  $res2 = $xml->xpath('//wsdl:portType/wsdl:operation');
  //print_r($res);
  foreach ($res2 as $child2)
  {
    //print_r($child2->children());
    echo 'child2'.PHP_EOL;
    print_r($child2->getName().PHP_EOL);
    print_r(count($child2->children()).PHP_EOL);
    print_r($child2);
    
    foreach ($child2->children() as $child3)
    {
      echo 'child3'.PHP_EOL;
      print_r($child3->getName().PHP_EOL);
      print_r(count($child3->children()).PHP_EOL);
      print_r($child3);
      foreach ($child3->children() as $child4)
      {
        echo 'child4'.PHP_EOL;
        print_r($child4->getName().PHP_EOL);
        print_r(count($child4->children()).PHP_EOL);
        print_r($child4);
      }
    }

  }
}
echo '</pre>';
?>

Expected result:
----------------
child2 & child3 & child4 should be printed..
 

child2
operation
2
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [name] => SOAP_set
        )

)
child2
operation
2
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [name] => SOAP_set
        )
   /* 2 another simplexml element input & output with children &
attributes*/
)

Actual result:
--------------
Only child2 prints with 0 children

child2
operation
0
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [name] => SOAP_set
        )

)
child2
operation
0
SimpleXMLElement Object
(
    [EMAIL PROTECTED] => Array
        (
            [name] => SOAP_get
        )

)

-- 
Edit bug report at http://bugs.php.net/?id=44108&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=44108&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44108&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44108&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44108&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44108&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44108&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44108&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44108&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44108&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44108&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44108&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44108&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44108&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44108&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=44108&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=44108&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44108&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44108&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44108&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44108&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44108&r=mysqlcfg

Reply via email to