简体   繁体   中英

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

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, ie :

firstNodeInList->secondNodeInList->thirdNodeInList.

Thank you

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM