Visual Basic - Leer XML en Visual Basic 6

Life is soft - evento anual de software empresarial
 
Vista:

Leer XML en Visual Basic 6

Publicado por Alvaro (1 intervención) el 27/05/2016 11:24:25
Buenos días, tengo un programa desarrollado en Visual Basic 6, que apenas tocaba y ahora me toca modificarle porque el programa es de gestión y el banco ha cambiado los ficheros de las remesas. Hasta ahora enviaba TXT y ahora mandan XML con otro formato.
Mi duda es que estoy intentando leer estos ficheros con Visual Basic y no lo consigo. Os muestro lo que hago y de que tipo es el XML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Private Function GetNodeValue(ByVal start_at_node As IXMLDOMNode, ByVal node_name As String, Optional ByVal default_value As String = "") As String
Dim value_node As IXMLDOMNode
Dim id As String
 
Set value_node = start_at_node.SelectSingleNode(".//" & node_name)
    id = value_node.Attributes.getNamedItem("ID").Text
 
    If value_node Is Nothing Then
        GetNodeValue = default_value
    Else
        GetNodeValue = id
    End If
End Function
 
Private Sub cargarXML()
Dim xml_document As DOMDocument
Dim values_node As IXMLDOMNode
Dim i As Integer
Dim j As Integer
 
On Error Resume Next
    ' Load the document.
    Set xml_document = New DOMDocument
    xml_document.Load "C:/arch.215.xml"
 
    ' If the file doesn't exist, then
    ' xml_document.documentElement is Nothing.
    If xml_document.documentElement Is Nothing Then
        ' The file doesn't exist. Do nothing.
        Exit Sub
    End If
 
    ' Find the Values section.
    Set values_node = xml_document.selectSingleNode("Document")
 
    ' Read the saved values.
 
For i = 0 To xml_document.documentElement.ChildNodes.Length
 
    Set values_node = xml_document.documentElement.ChildNodes(i)
    txtarchivo.Text = GetNodeValue(values_node, "Record", "???")
Next i
End Sub


El XML es de este tipo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="UTF-8"?>
 
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03">
<CstmrPmtStsRpt>
<GrpHdr>
<MsgId>123342342342342342</MsgId>
<CreDtTm>2016-05-24T06:00:01</CreDtTm>
<InitgPty>
<Id>
<OrgId>
<BICOrBEI>xxxxxxxx</BICOrBEI>
</OrgId>
</Id>
</InitgPty>
</GrpHdr>................
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder