DOMNode* current = // get current node DOMNode* nextSibling = current->getNextSibling(); if(nextSibling != NULL) { // do something with the next sibling node }
DOMNode* sibling = // get a node's sibling while(sibling != NULL) { // do something with the current sibling node sibling = sibling->getNextSibling(); }In this example, a valid pointer to a node's sibling is retrieved and a while loop is used to iterate through all subsequent siblings. The loop will continue until there are no more siblings to retrieve. The C++ DOMNode getNextSibling function is part of the DOM library, which is included in many C++ packages and libraries, including Xerces-C++, TinyXML, and Poco XML.