how to figure out if the present node is the last child of the parent's node

Posted by Bacon on Stack Overflow See other posts from Stack Overflow or by Bacon
Published on 2010-04-16T11:03:00Z Indexed on 2010/04/16 11:13 UTC
Read the original article Hit count: 373

Filed under:
|
|

Hello,

I'm trying to figure out how to know if a node is the last child of another, or not. I know how to retrieve the parent's lastChild name ($node->parentNode->lastChild->nodeName), but as sometimes there's many same node names within the same parent, the name is definitly not the way to find the last child.

I'm looking for some kind of iterator which can retrieve the number of childs, and depending of the position of the current node, tell if the current node is the last child.

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml