|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66044 SimpleXMLElement::children
Submitted: 2013-11-07 09:49 UTC Modified: 2013-11-07 18:19 UTC
From: contact at cosminsandu dot ro Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: Irrelevant OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: contact at cosminsandu dot ro
New email:
PHP Version: OS:


 [2013-11-07 09:49 UTC] contact at cosminsandu dot ro
the SimpleXMLElement::children does not return correct children(s) if the namespace is defined in child element

Test script:

Expected result:
the q1 element:

    <q1:login xmlns:q1="THE NAMESPACE I NEED">
        <user xsi:type="xsd:string">user</user>
        <password xsi:type="xsd:string">pass</password>

Actual result:
the $body_node->count() return 0; 
and $body_node->children()->asXML() returns false.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-07 18:19 UTC]
-Status: Open +Status: Not a bug
 [2013-11-07 18:19 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

children() and attributes(), as well as ->, will only return children/attributes of the "current namespace", which uses the default of xmlns="". To switch namespaces pass arguments.

$xml = new SimpleXMLElement("your XML", 0, false);
$body_node = $xml->children("soap", true)->Body;
$login_node = $body_node->children("q1", true)->login;
$user_node = $login_node->children("")->user;
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 04:01:28 2024 UTC