Problem with DOMDocuments

JackKaptijn

Registered User.
Local time
Today, 23:45
Joined
Dec 10, 2012
Messages
38
Hello,
My previous post was solved but the problem isn't.
I am trying the get specific data out of an XML file. I managed to access a nodelist but I need more data.

This is the XML file:
Code:
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="removed due to #posts">
  <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>

This is the code to start with:
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 extra data I need are the IBAN and Ustrd field. But they are on a different level in the XML. I tried selectSingleNode but no solution yet.

Any help?
Jack
 
get the free xml notepad to see what is what
 

Users who are viewing this thread

Back
Top Bottom