tags:

views:

26

answers:

1

Using MSXML4, I am creating and saving an xml file:

MSXML2::IXMLDOMDocument2Ptr m_pXmlDoc;
//add some elements with data
SaveToDisk(static_cast<std::string>(m_pXmlDoc->xml));

I now need to acquire a substring from m_pXmlDoc->xml and save it. For example, if the full xml is:

<data>
    <child1>
        <A>data</A>
            <One>data</One>
        <B>data</B>
    </child1>
</data>

I want to store this substring instead:

<A>data</A>
    <One>data</One>
<B>data</B>

How do I get this substring using MXML4?

+1  A: 

Use XPath queries. See the MSDN documentaion for querying nodes. Basically you need to call the selectNodes API with the appropriate XPath expression that matches the part of the DOM you are interested in.

// Query a node-set.
MSXML4::IXMLDOMNodeListPtr pnl = pXMLDom->selectNodes(L"//child/*");
dirkgently