28 maj 2005 kl. 19.32 skrev Jared Williams:
childNodes contains the textnodes too, in this case the whitespace
between each of <element>.
So, to put it in short words; how do I do to browse the
content of the element id="5" withuot doing it recursively? I
want to receive a list when I call childNodes (or equivalent)
that gives me the elements with id 51-56, and a length of 6.
for($child = $elements->item(0)->firstChild; $child; $child =
$child->nextSibling)
if ($child->nodeType == XML_ELEMENT_NODE)
echo $child->getAttribute('id'), "\n";
Thanks for the answer!
It doesn't really work in my case, since I'm trying to create a
recursive function according the following:
1. I perform a search using xPath and get a search result as a
DOMNodeList.
2. This list I send to a function that takes it as input, and whats
function is to create a multidimensional array.
3. Foreach item in the list I check if it has any children.
4. If so, I do the recursive call, with the list of children as input.
So far so good, but when I come to the second loop, when the input is
the list from the childNodes, everything stops working...
Sincerely
Victor