Getting node values separately using msxml parser in vc++? RRS feed

  • Question

  • In the below example how can i get the text values separately like : { {i am parent text}, {i am child1}, {i am child2}, {with above childs} } using {get_nodeValue} property in MSXML using c++ : {<rootElement>} {<parent>i am parent text} {<child_1>i am child1</child_1>} {<child_2>i am child2</child_2>} {with above childs} {</parent>} {</rootElement>} here when i am using {get_nodeValue()} for the {parent} element, i am getting null as it is of NODE_ELEMENT type. i have referred following link :


    Here is the code used:

    ParseCurrentNode(IXMLDOMNode* CurrentNode) { VARIANT nValNode; BSTR bstrNodeText; CString strNodeText; Nodevalue->get_text(&bstrNodeText); strNodeText = bstrNodeText; SysFreeString(bstrNodeText); HRESULT temphr=FormatNode->get_nodeValue(&nValNode); } result is: strNodeText (concatenated string)="i am parent text i am child1 i am child2 with above childs" nValNode = null; Here CurrentNode is "parent": <rootelement> <parent>i am parent text <child1>i am child 1</child1> <child2>i am child 2</child2>

    with above childs


    Tuesday, April 14, 2020 11:32 AM

All replies

  • Try getting the child nodes using CurentNode->get_childNodes(…). You will probably obtain four children: text node, child1 element, child2 element, text node. Use get_text to get the inner text of each child. Or get_nodeType to investigate the types.

    Tuesday, April 14, 2020 6:20 PM
  • Viorel Thanks for your reply.

    with your suggested method i text for child1 and child2 but i need parent node text split separately as well in this{i am parent text, with above childs}.

    Could you please tell me how can i get this .

    • Edited by Rajekish Wednesday, April 15, 2020 2:32 AM
    Wednesday, April 15, 2020 2:31 AM
  • Please help in answering the question.
    Monday, April 20, 2020 3:19 AM