Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / March 2007

Tip: Looking for answers? Try searching our database.

MSXML6 C++ VS2005: parsing "set" of nodes (& child nodes)??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
j.a. harriman - 21 Mar 2007 19:09 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.