Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS XML DOM Question

Status
Not open for further replies.

mmorancbt

IS-IT--Management
Nov 11, 2002
367
US
I can iterate through nodes using the MS XML DOC, evaluating node by node, however, how can I return a specific nodes value inside of an XML element. For instance,

I receive a document with 1 or more orders
Code:
<ReceivedOrders>
  <order>
     <customername>Joe Smith</customername>
     <Items>
       <Item>
           <name>A product</name>
           <price>2.95</price>
           <quantity>2</quantity>
       </item>
       <item>
           <name>another product</name>
           <price>10.00</price>
           <quantity>1</quantity>
       </item>
     </Items>
  </order>
  <orders>
     <customername>Joe Smith</customername>
     <Items>
       <Item>
           <name>A product</name>
           <price>2.95</price>
           <quantity>2</quantity>
       </item>
       <item>
           <name>another product</name>
           <price>10.00</price>
           <quantity>1</quantity>
       </item>
     </Items>
  </order>
</ReceivedOrders>
[code]

I would like to, return the number of <order> elements in a <ReceivedOrders> block and the number of <items> within a specific <order> block.

I would like to return the customer name from any given <order> block - for instance.  I can iterate through, just can't seem to return a particular element's value from a particular block?

Am I making sense?

Thanks.

Matthew Moran
Read my career blog at: [URL unfurl="true"]http://www.cbtoolkit.com[/URL]
Career Blog: [URL unfurl="true"]http://blogs.ittoolbox.com/pm/career/[/URL]
[i]Todo esta bien.. Todo esta divertido (it's all good, it's all fun)[/i]
 
Okay, premature inquiry...

selectNodes and selectSingeNode did the trick.

Example:
xdoc.childnodes(0).selectsinglenode("order/customername/").text

Returns "Joe Smith"

Matthew Moran
Read my career blog at: Career Blog: Todo esta bien.. Todo esta divertido (it's all good, it's all fun)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top