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

XML VBA Selecting Childnodes

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
An extension to my earlier question,

Code:
<?xml version="1.0"?>
 <TAXPACKS>
 <CLIENT CLIENTNO='37509'>
  <CLIENTTYPE>1</CLIENTTYPE> 
  <CLIENTWRAPNO>200037</CLIENTWRAPNO> 
   <CTC>
 <RECORD>
  <CTCHEADING>Interest UK Companies</CTCHEADING> 
 <DATA>
  <PAYDATE>01/02/2005</PAYDATE> 
  <STOCK>Made Up company Acc</STOCK> 
  <HOLDING>1211.19</HOLDING> 
  <RATE>0.016</RATE> 
  <GROSS>186.670625463221</GROSS> 
  <TAX>167.29</TAX> 
  <NET>19.37904</NET> 
  <EQUALISATION>0</EQUALISATION> 
  </DATA>
 <DATA>
  <PAYDATE>30/08/2005</PAYDATE> 
  <STOCK>New Made Up Bond Inc</STOCK> 
  <HOLDING>103.55</HOLDING> 
  <RATE>0.5</RATE> 
  <GROSS>498.728091451292</GROSS> 
  <TAX>446.95</TAX> 
  <NET>51.775</NET> 
  <EQUALISATION>0</EQUALISATION> 
  </DATA>
</RECORD>
 <RECORD>
  <CTCHEADING>DIVIDENDS UK Companies</CTCHEADING> 
 <DATA>
  <PAYDATE>01/02/2005</PAYDATE> 
  <STOCK>Made Up company Acc</STOCK> 
  <HOLDING>1211.19</HOLDING> 
  <RATE>0.016</RATE> 
  <GROSS>186.670625463221</GROSS> 
  <TAX>167.29</TAX> 
  <NET>19.37904</NET> 
  <EQUALISATION>0</EQUALISATION> 
  </DATA>
</RECORD>
</CTC>
</CLIENT>
</TAXPACKS>

What I am trying to do is move down to the CTC Section and move through the records, I have been playing around with childnodes/nextsiblings/

Code:
Sub testingFORctc()
Dim xml_doc As New DOMDocument
Dim nde_Client As IXMLDOMNode
Dim nde_CTC As IXMLDOMElement
Dim nde_item As IXMLDOMElement
Dim x As Variant
'On Error Resume Next


xml_doc.Load str_XMLPath & "TaxPackBatch.xml"

Set nde_Client = xml_doc.documentElement

For Each nde_Client In nde_Client.selectNodes("//CLIENT [@CLIENTNO='37509']")
   For Each nde_CTC In nde_Client.selectNodes("CTC").childNodes
        If nde_CTC.selectSingleNode("CTC HEADING").Text = "INTEREST UK COMPANIES" Then
            'Run Interest code
        ElseIf nde_CTC.selectSingleNode("CTC HEADING").Text = "Dividends UK COMPANIES" Then
            'run Dividend code
        End If
        
   Next
Next

Set xml_doc = Nothing

End Sub

Chance,

Filmmaker, taken gentleman and He tan e epi tas
 
I think i have it with

Code:
For Each nde_CTC In nde_Client.selectNodes("CTC").Item(0).childNodes

but it doesnt seem a clean approach to me.

Chance,

Filmmaker, taken gentleman and He tan e epi tas
 
How about:
Code:
For Each Record In nde_Client.selectNodes("/TAXPACKS/CLIENT[@CLIENTNO='37509']/CTC/RECORD")

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top