Here is my parsing code:
MSXML2::IXMLDOMNodePtr pNode = m_pXmlDoc->selectSingleNode(kNameOfChild.c_str());
MSXML2::IXMLDOMNodeListPtr pIDOMNodeList = NULL;
MSXML2::IXMLDOMNodePtr pIDOMNode = NULL;
long numOfChildNodes= 0;
BSTR bstrItemText;
HRESULT hr;
MSXML2::IXMLDOMElementPtr pChildNode = m_pXmlDoc->getElementsByTagName(kNameOfChild.c_str());
hr = m_pXmlDoc->get_childNodes(&pIDOMNodeList);
hr = pIDOMNodeList->get_length(&numOfChildNodes);
And my xml file:
<?xml version="1.0"?>
<GovTalkMessage>
<EnvelopeVersion>1.0</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>MOSWTSC2</Class>
<Qualifier>acknowledgement</Qualifier>
<Function>submit</Function>
<TransactionID>20021202ABC</TransactionID>
<CorrelationID>B07B9ED3176193DDC4EC39063848A927</CorrelationID>
<ResponseEndPoint PollInterval="10">
https://secure.gateway.gov.uk/poll
</ResponseEndPoint>
<GatewayTimestamp>2001-01-31T10:20:18.345</GatewayTimestamp>
</MessageDetails>
<SenderDetails/>
</Header>
<GovTalkDetails>
<Keys/>
</GovTalkDetails>
<Body/>
</GovTalkMessage>
- kNameOfchild is "Qualifier"
- pNode is always NULL
- pChildNode is always NULL
- hr returns
S_OK
- numOfChildNodes is always 0
So, what am I doing wrong? Thanks
Try /GovTalkMessage/Header/MessageDetails/Qualifier for the XPath query.