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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to extract a value from a multi level xml using criteria

Status
Not open for further replies.

willybhere

Technical User
Jun 28, 2013
3
US
Hi,
i am trying to extract a value from a multi level xml. i am able to select the items based on one criteria but am having no luck adding a second criterion which would them allow me to target that item to extract the value i need.

Set NodeList = xmlDocTS.documentElement.selectNodes(itemNode)
Set ConditionNode1 = xmlDocTS.documentElement.selectNodes(transtypeNode)
Set ConditionNode2 = xmlDocTS.documentElement.selectNodes(settledateNode)
Set ValueNode = xmlDocTS.documentElement.selectNodes(transidNode)

For Each Node In ConditionNode1
If Node.text = "AW" Then
msgbox "trans type matches " &Node.text
Else msgbox (Node.text)
End If
Next

could anyone point out some examples i can use that may help.

regards, wil
 
I would go with a suitable XPath.
Can you post a part of that XML along with which node values you wish to extract?

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
hey, thanks for helping.

here is the xml i am processing:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=" xmlns:xsi=" xmlns:xsd=" <SOAP-ENV:Body>
<ns1:getTradesSummResponse SOAP-ENV:encodingStyle=" xmlns:ns1="urn:webAXIS:webAXIS">
<eTradesSumm xsi:type="ns1:ArrayOfgetTradesSumm_eTradesSummRow" SOAP-ENC:arrayType="ns1:getTradesSumm_eTradesSummRow[]" xmlns:SOAP-ENC=" <Item xsi:type="ns1:getTradesSumm_eTradesSummRow">
<transId xsi:type="xsd:decimal">125893632</transId>
<settleDate xsi:type="xsd:date">2004-02-18</settleDate>
<transType xsi:type="xsd:string">PW</transType>
<settle xsi:type="xsd:string">*</settle>
</Item>
<Item xsi:type="ns1:getTradesSumm_eTradesSummRow">
<transId xsi:type="xsd:decimal">753556499</transId>
<settleDate xsi:type="xsd:date">2002-08-15</settleDate>
<transType xsi:type="xsd:string">AW</transType>
<settle xsi:type="xsd:string">*</settle>
</Item>
<Item xsi:type="ns1:getTradesSumm_eTradesSummRow">
<transId xsi:type="xsd:decimal">354885120</transId>
<settleDate xsi:type="xsd:date">2002-02-15</settleDate>
<transType xsi:type="xsd:string">AW</transType>
<settle xsi:type="xsd:string">*</settle>
</Item>
</eTradesSumm>
<pcExcStatus xsi:type="xsd:string" />
<piTotalRow xsi:type="xsd:int">3</piTotalRow>
<piCurrIndex xsi:type="xsd:int">3</piCurrIndex>
</ns1:getTradesSummResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


itemNode = "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getTradesSummResponse/eTradesSumm/Item"
transtypeNode = "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getTradesSummResponse/eTradesSumm/Item/transType"
settledateNode = "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getTradesSummResponse/eTradesSumm/Item/settleDate"
transidNode = "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getTradesSummResponse/eTradesSumm/Item/transId"


I am successful getting the root and first child but I cannot go any deeper. Further calls using:
SetRootElement
ChildElements
ChildElementsByPath
all return Object doesn't support this property or method.

I need to use ../Item as the root and then For..Each or Do..Until the transtypeNode = AW and settledateNode = 2002-08-15. If these conditions are met, then get the value associated with transidNode.

Appreciate any direction.

thanks, w
 
Yep, that it exactly what I meant.
Good you got it sorted!
[thumbsup2]

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top