Problem finding a specific tags in XML

JackKaptijn

Registered User.
Local time
Today, 05:58
Joined
Dec 10, 2012
Messages
38
I am using Access 2007.
I have got an XML file with the folowwing structure:

Code:
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="redirect to the (link is removed!) XMLSchema-instance">
<CstmrDrctDbtInitn>
<GrpHdr>
<MsgId>006-2012-11-09-12:21:47</MsgId>
<CreDtTm>2012-10-12T12:21:47</CreDtTm>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>477.01</CtrlSum>
<InitgPty>
<Nm>Customer</Nm>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>006-24-1</PmtInfId>
<CdtrAcct>
<Id>
<IBAN>NL61RABO0104871865</IBAN> 
</Id>
<Ccy>EUR</Ccy>
</CdtrAcct>
<CdtrAgt>
<FinInstnId>
<BIC>RABONL2U</BIC>
</FinInstnId>
</CdtrAgt>
<DrctDbtTxInf>
<PmtId>
<EndToEndId>80057/20121012122044/12700007</EndToEndId>
</PmtId>
<InstdAmt Ccy="EUR">123.45</InstdAmt>
<DbtrAcct>
<Id>
<IBAN>NL61RABO0104871865</IBAN>
</Id>
</DbtrAcct>
<RmtInf>
<Ustrd>XX080057/12700007XX</Ustrd>
</RmtInf>
</DrctDbtTxInf>
</PmtInf>
<PmtInf>
<PmtInfId>006-24-2</PmtInfId>
<CdtrAcct>
<Id>
<IBAN>NL61RABO0104871865</IBAN>
</Id>
<Ccy>EUR</Ccy>
</CdtrAcct>
<CdtrAgt>
<FinInstnId>
<BIC>RABONL2U</BIC>
</FinInstnId>
</CdtrAgt>
<DrctDbtTxInf>
<PmtId>
<EndToEndId>80058/20121012122118/12700008</EndToEndId>
</PmtId>
<InstdAmt Ccy="EUR">353.56</InstdAmt>
<DbtrAcct>
<Id>
<IBAN>NL32INGB0000012345</IBAN>
</Id>
</DbtrAcct>
<RmtInf>
<Ustrd>XX080058/12700008XX</Ustrd>
</RmtInf>
</DrctDbtTxInf>
</PmtInf>
</CstmrDrctDbtInitn>
</Document>
So you can see, the tag <DrctDbtTxInf> is iterating.
I need some data from each record.

This code is a start:
Code:
Private Sub NameSpace_Click()
    Dim strFile As String
    Dim xDoc As DOMDocument
    Set xDoc = New DOMDocument
    Dim Nodes As IXMLDOMNodeList
    Dim xNode As IXMLDOMNode
 
    strFile = "D:\Documenten\OFA5\Sepa\SDD003.XML"
    xDoc.async = False
    If xDoc.Load(strFile) Then
        Set Nodes = xDoc.selectNodes("//CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf/PmtId")
        For Each xNode In Nodes
            i = i + 1
            Debug.Print i & "|" & xNode.Text
        For j = 0 To xNode.childNodes.length - 1
                Debug.Print j & "|" & xNode.childNodes.Item(j).nodeName & "|" & xNode.childNodes.Item(j).hasChildNodes
            Next j
        Next xNode
    Else
        MsgBox "Document not loaded"
    End If
    Set xDoc = Nothing
 
End Sub

The two extra fields I need are the <IBAN> and the <Ustrd>.
But they are on a different level. I tried to use selectSingleNode but I do not understand the use.

Somebody an idea?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom