Search code examples
c++msxml

MSXML2: How can I get value of a node?


I have this node

MSXML2::IXMLDOMNodePtr node;    

node->Getxml() returns "<level3>333<level4 atribute="444"><level5>555<level6>666</level6></level5></level4></level3>"

node->Gettext(); returns "333555666"

node->GetnodeValue() throws exception if node is not an attribute.

How can I get the value 333 ???


Solution

  • You have to walk the children of the node you have in hand - you can get a list using childNodes after checking the node has children of course, then you can use Gettext() to extract the individual element texts.

    It's quite painful to code to the MSXML DOM, in my experience. Glad to see you are using the built-in smart pointers, anyway.