JackKaptijn
Registered User.
- Local time
- Today, 18:01
- Joined
- Dec 10, 2012
- Messages
- 38
For weeks I am trying to read an XML file which needs to be processed in an Access database. I can not find the proper way to:
- find a specific node
- iterate from there
The XML file is an international bank file:
I started quit simple, just wanted to read to node MsgId.
This is the code I use:
Whatever I try: //MsgId or MsgId the results is "No nodes".
Can someone please help me how to read to XML.
Besides reading one node, the next challenge will be iterating the PmtInf node. There can be 1 in the XML file but also 50.
Thanks in advance.....
Jack
- find a specific node
- iterate from there
The XML file is an international bank file:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="[URL]http://www.w3.org/2001/XMLSchema-instance[/URL]">
[INDENT]
<GrpHdr>
[INDENT]
<MsgId>001-2013-09-19-18:12:17</MsgId>
<CreDtTm>2013-08-23T18:12:17</CreDtTm>
<NbOfTxs>3</NbOfTxs>
<CtrlSum>140.00</CtrlSum>
<InitgPty>
<Nm>DEMO</Nm>
</InitgPty>
[/INDENT]
</GrpHdr>
<PmtInf>
[INDENT]
<PmtInfId>001-9-1</PmtInfId>
<PmtMtd>DD</PmtMtd>
<BtchBookg>false</BtchBookg>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>95.00</CtrlSum>
<CdtrAcct>
[INDENT]
<Id>
<IBAN>NL52RABO0376585323</IBAN>
</Id>
[/INDENT]
</CdtrAcct>
[/INDENT]
</PmtInf>
<PmtInf>
[INDENT]
<PmtInfId>001-9-2</PmtInfId>
<PmtMtd>DD</PmtMtd>
<BtchBookg>false</BtchBookg>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>45.00</CtrlSum>
<CdtrAcct>
[INDENT]
<Id>
<IBAN>NL52RABO0376585323</IBAN>
</Id>
[/INDENT]
</CdtrAcct>
[/INDENT]
</PmtInf>
[/INDENT]
<Document>
This is the code I use:
Code:
Private Sub ReadXML_Click()
Dim aDoc As DOMDocument60
Dim aNode As IXMLDOMNode
Set aDoc = New MSXML2.DOMDocument60
aDoc.async = False
aDoc.Load DLookup("C:\Sample.XML")
Set aNode = aDoc.selectSingleNode("//MsgId")
If aNode Is Nothing Then
MsgBox "No nodes selected."
Else
MsgBox = aNode.Text
End If
Set aDoc = Nothing
Exit Sub
Whatever I try: //MsgId or MsgId the results is "No nodes".
Can someone please help me how to read to XML.
Besides reading one node, the next challenge will be iterating the PmtInf node. There can be 1 in the XML file but also 50.
Thanks in advance.....
Jack