Hi,
I've looked at a number of examples in the MSXML6 help, but haven't been
able to find exactly what I'm looking for.
I have the following loaded into a "IXMLDOMDocument2" object.
I have a CString sString that I would like to check to see if it matches one
of the "Descriptions" below. If it does match, I want to be able to extract
the corresponding "Amount" field to use it elsewhere in the program.
<InquiryResponse>
<Balances>
<Balance>
<Amount>246326.04</Amount>
<Description>Available Balance</Description>
</Balance>
<Balance>
<Amount>246326.04</Amount>
<Description>Current Balance</Description>
</Balance>
</Balances>
</InquiryResponse>
I've looked at the "selectSingleNode", "get_nodeName", "get_xml",
"get_text", and "selectNodes" functions as well as the "IXMLDOMNodeList"
object.
I started hacking something together like:
IXMLDOMDocument2 *pXMLDom=NULL;
bstr2 = SysAllocString(L"//Balance");
hr = pXMLDom->selectNodes(bstr2, &pNodeList);
long max = 0;
hr = pNodeList->get_length(&max);
IXMLDOMNode *pNode2=NULL;
for (long idx = 0; idx < max; idx++)
{
pNodeList->get_item(idx, &pNode2);
}
It all seems rather ackward & clunky to get the info out of the DOM object.
Maybe that's the way MSXML goes.
Can someone point me to a good example (MSDN or other) that would do what
I'm looking to accomplish?
Thanks. Jeff
Martin Honnen - 22 Mar 2007 13:57 GMT
> I have a CString sString that I would like to check to see if it matches one
> of the "Descriptions" below. If it does match, I want to be able to extract
[quoted text clipped - 12 lines]
> </Balances>
> </InquiryResponse>
Use selectSingleNode with the XPath expression
/InquiryResponse/Balances/Balance[Description = 'Current Balance']/Amount
Then check whether the result is not null and if so access its text
property.
Can't help with the C++ doing that but the use of MSXML should be clear
I hope.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/