Fix #4: extra ->children() should show for prefixed root element

This commit is contained in:
Rowan Collins 2017-11-09 21:07:32 +00:00
parent f3238d95c0
commit 6ac7c40043
2 changed files with 29 additions and 20 deletions

View file

@ -124,11 +124,19 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string
}
// To what namespace does this element belong? Returns array( alias => URI )
// For top-level elements, cheat, and say they're in the null namespace, to force a ->children() call
if ( $depth == 1 )
{
$item_ns = array('' => NULL);
}
else
{
$item_ns = $item->getNamespaces(false);
if ( !$item_ns )
{
$item_ns = array('' => NULL);
}
}
// This returns all namespaces used by this node and all its descendants,
// whether declared in this node, in its ancestors, or in its descendants

View file

@ -1,5 +1,6 @@
SimpleXML object (1 item)
[0] // <movies>
->children('', true)
->movie[0]
->title[0]
->characters[0]