0

I have the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<lastconnectedServers>
   <Server ip="172.24.18.240" domain="MyDomain">
        <SharedFolder name="MyShared" type="FTP"/>
        <SharedFolder name="Share1" type ="CIFS"/>
        <SharedFolder name="Share2" type ="both"/>
   </Server>
</lastconnectedServer>

I need to read Attribute and Node values. I am able to get the number of child nodes but unsure how to get the value:

CComPtr<IXMLDOMDocument> pIxmlDOC = NULL;
    CComPtr<IXMLDOMParseError> pIxmlDOM = NULL;
    CComPtr<IXMLDOMElement> pIxmlServerElement;
    CComPtr<IXMLDOMNode> pIxmlServerNode,pIxmlLastConnectedServerNode;
    CComPtr<IXMLDOMNodeList> pIXmlNodeChildList = NULL;


    IXMLDOMNode* pInsertedNode;

    BSTR bstrXML = NULL;
    VARIANT vXMLSource;
    VARIANT_BOOL bIsSuccess;
    HRESULT hr = CoInitialize(NULL);

    LONG lChildCount = 0;

    CHK_HR(CreateAndInitDOM(&pIxmlDOC));    
    VariantFromString(L"stocks.xml",vXMLSource);

    pIxmlDOC->load(vXMLSource,&bIsSuccess);

    pIxmlDOC->get_childNodes(&pIXmlNodeChildList);

        pIXmlNodeChildList->get_length(&lChildCount);

        for(int i = 0; i < lChildCount; i++)
        {
            CComPtr<IXMLDOMNamedNodeMap> pIXMLNodeMap;
            CComPtr<IXMLDOMNode> pIXMLChildNode;

            pIXmlNodeChildList->get_item(i,&pIXMLChildNode);
            pIXMLChildNode->get_attributes(&pIXMLNodeMap);

        }
Simsons
  • 12,295
  • 42
  • 153
  • 269

2 Answers2

0

A quick search through MSDN would have saved you a lot of time:

HRESULT getNamedItem(
    BSTR name,
    IXMLDOMNode **namedItem);

See: http://msdn.microsoft.com/en-us/library/ms767592(v=VS.85).aspx

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
0

Looking in MSDN:

http://msdn.microsoft.com/en-us/library/ms761386

It seems that IXMLDOMNode has the text pointer, that points to the contents of the node:

text* : Represents the text content of the node or the concatenated text representing the node and its descendants. Read/write.
Baltasarq
  • 12,014
  • 3
  • 38
  • 57