Repository navigation
Conversation
Truta446
commented
Oct 27, 2026
…erties The property table of a SimpleXMLElement returned by children() was built starting at the first element child and then walking all following siblings. Processing instructions and comments were therefore included only when they appeared after the first element, unlike for the element itself. Start at the first child instead. Text nodes are still skipped, so an element containing only text keeps having no children.
a410473 to
1428f37
Compare
|
Hi @Truta446, there is an inconsistency Can we add the following as test case ? foreach ([
'<c><?pi a?></c>',
'<c><!-- c --></c>',
'<c>t<?pi a?></c>',
'<!DOCTYPE c [<!ENTITY e "v">]><c>&e;<x/></c>',
] as $xml) {
$sxe = simplexml_load_string($xml);
echo $xml, ': ', json_encode(array_keys((array) $sxe->children())), PHP_EOL;
}
$sxe = simplexml_load_string('<c xmlns:a="urn:a"><?pi a?><y/><a:x/></c>');
var_dump(array_keys((array) $sxe->children('urn:a'))); |
Keep the property table of children() consistent with sxe_prop_is_empty(): an element whose only children are PIs or comments (or with no child in the requested namespace) is still empty, so (bool) and (array) agree.
|