Fix #4: extra ->children() should show for prefixed root element
This commit is contained in:
parent
f3238d95c0
commit
6ac7c40043
2 changed files with 29 additions and 20 deletions
|
@ -122,14 +122,22 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string
|
||||||
. PHP_EOL;
|
. PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To what namespace does this element belong? Returns array( alias => URI )
|
// To what namespace does this element belong? Returns array( alias => URI )
|
||||||
$item_ns = $item->getNamespaces(false);
|
// For top-level elements, cheat, and say they're in the null namespace, to force a ->children() call
|
||||||
if ( ! $item_ns )
|
if ( $depth == 1 )
|
||||||
{
|
{
|
||||||
$item_ns = array('' => NULL);
|
$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,
|
// This returns all namespaces used by this node and all its descendants,
|
||||||
// whether declared in this node, in its ancestors, or in its descendants
|
// whether declared in this node, in its ancestors, or in its descendants
|
||||||
$all_ns = $item->getNamespaces(true);
|
$all_ns = $item->getNamespaces(true);
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
SimpleXML object (1 item)
|
SimpleXML object (1 item)
|
||||||
[0] // <movies>
|
[0] // <movies>
|
||||||
->movie[0]
|
->children('', true)
|
||||||
->title[0]
|
->movie[0]
|
||||||
->characters[0]
|
->title[0]
|
||||||
->character[0]
|
->characters[0]
|
||||||
->name[0]
|
->character[0]
|
||||||
->actor[0]
|
->name[0]
|
||||||
->character[1]
|
->actor[0]
|
||||||
->name[0]
|
->character[1]
|
||||||
->actor[0]
|
->name[0]
|
||||||
->plot[0]
|
->actor[0]
|
||||||
->great-lines[0]
|
->plot[0]
|
||||||
->line[0]
|
->great-lines[0]
|
||||||
->rating[0]
|
->line[0]
|
||||||
['type']
|
->rating[0]
|
||||||
->rating[1]
|
['type']
|
||||||
['type']
|
->rating[1]
|
||||||
|
['type']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue