To all,

I have a doc that I am trying to go through recursively and find every child
using DOM. THen, if I want the child, I will put it into one of two or three
linked lists or vectors. 

My doc that I am parsing is something like this:
<?xml version="1.0"?><Title><x1>value1<a>"a value"</a><b>"another
value"</b></x1><x2>value2<aa>"aa value"</aa></x2><Title>

DOMDocument * doc = parser->getDocument();
DOMElement * elm = doc->getDocumentElement();
const XMLCh* nodeName = elm->getNodeName();

DOMNodeList * list = elm->getChildNodes();
int x = list->getLength();
int y = 0;
while (y < x) {

   cout << "child " << y << " is " <<
XMLString::transcode(list->item(y)->getNodeName())<< endl;
 
   DOMNode * grandChild = list->item(y)->getFirstChild();

   if (!grandChild->hasChildNodes()){
       //this is where to get the child nodes, but so far I just get the
same children again.
       //so I think there is a big error here

       DOMNode * grandChild2 = list->item(y)->getFirstChild();
       cout << "Child " << y << " has a node value of " <<
XMLString::transcode(grandchild->getNodeValue()) << endl;
       //then, more of the same to get the great Grandchildren....

   }
    y++;
}

Thanks much for all of your help and have a great Holiday!

So, how do I set it up recursively to get all the children of children?
Also, I haven't gotten attributes or no whitespace to work yet, so my
document is still mushed all together.

Sarah

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to