Getting the main list of nodes from xml document, using msxml lib in c++

781 views Asked by At

I would like to go through the whole xml document that I have, without depending in the actual id value, node name or attributes. I use the msxml3 lib.

I would like to get a list of the main nodes in the xml, that are descendants of the main node.

<mainNode>

  <firstNodeInList></firstNodeInList>

  <secondNodeInList></secondNodeInList>

  <thirdNodeInList></thirdNodeInList>

</mainNode>

I would like to get a list of the inside nodes, i.e. :

firstNodeInList->secondNodeInList->thirdNodeInList.

Thank you

1

There are 1 answers

0
Noam Ohana On BEST ANSWER

Since no one responded, I had to find out the answer, which apperently is very simple. The first line will get the document element, or the root element. The second will get the list of children of the root.

MSXML2::IXMLDOMElementPtr docElem = m_newFileDoc->documentElement;
MSXML2::IXMLDOMNodeListPtr nodes = docElem->childNodes;