Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Leer XML

Estas en el tema de Leer XML en el foro de Visual Basic clásico en Foros del Web. Hola. Primero aclararo que soy nuevo en XML. Estoy leyendo un archivo .xml que tiene una estructura mas o menos asi: 1 2 3 3 ...
  #1 (permalink)  
Antiguo 01/08/2006, 09:21
 
Fecha de Ingreso: julio-2006
Mensajes: 98
Antigüedad: 17 años, 9 meses
Puntos: 0
Leer XML

Hola. Primero aclararo que soy nuevo en XML. Estoy leyendo un archivo .xml que tiene una estructura mas o menos asi:

1
2
3
3
4
4
3

1
2
3
3
4
4
3

Cada nro es un "nodo" xml. Yo quisiera que mi programa VB lea:

a) Cuantos nivel 1 hay ?
b) Dentro de cada nivel 1, cuantos niveles 2 hay ?
c) Dentro de cada nivel 2, cuantos niveles 3 hay ?

================= Mi programa VB =======================
Dim oXMLDom As New DOMDocument40


Private Sub Form_Load()

Dim ws_ligne, ws_colonne
Dim fs, f, f1, fc, s
Dim extension_file As String

On Error GoTo err1

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(App.Path)
Set fc = f.Files


For Each f1 In fc
extension_file = Right(f1.Name, 4)

If extension_file = ".xml" Then
' Load an xml document into a DOM instance.
oXMLDom.async = False
oXMLDom.validateOnParse = False
oXMLDom.resolveExternals = False
oXMLDom.preserveWhiteSpace = True
If oXMLDom.Load(App.Path + "\" + f1.Name) = False Then
MsgBox "Failed to load xml data from file."
Exit Sub
End If

Call xml_file_issued_niveau2("Issued")
End If
Next


On Error GoTo 0


err1:
MsgBox err.Number, err.Description
End

End Sub
----------------------------------------------
Sub xml_file_issued_niveau2(ws_node_name1)

Dim oNodes2 As IXMLDOMNodeList
Set oNodes2 = oXMLDom.selectNodes("//" & ws_node_name1 & "[1]/*")

For i2 = 0 To oNodes2.length - 1
Set oNode2 = oNodes2.nextNode
If Not (oNode2 Is Nothing) Then
sName = oNode2.nodeName
sData = oNode2.xml
Call xml_file_issued_niveau3(oNode2.nodeName)
End If
Next

End Sub
-------------------------------------------
Sub xml_file_issued_niveau3(ws_node_name2)

' Query a node-set (niveau 3).



Dim oNodes3 As IXMLDOMNodeList
Set oNodes3 = oXMLDom.selectNodes("//" & ws_node_name2 & "[1]/*")

For i3 = 0 To oNodes3.length - 1
Set oNode3 = oNodes3.nextNode
If Not (oNode3 Is Nothing) Then
sName = oNode3.nodeName
Select Case sName
Case "SerialNumber"
garder_serial_number = oNode3.Text
Case "BusinessUnit"
Call xml_file_issued_niveau4(oNode3.nodeName)
End Select
End If
Next

End Sub
------------------------------------------------
Sub xml_file_issued_niveau4(ws_node_name3)

' Query a node-set (niveau 4).

Dim oNodes4 As IXMLDOMNodeList
'Set oNodes3 = oXMLDom.selectNodes("//BusinessUnit[1]/*")
Set oNodes4 = oXMLDom.selectNodes("//" & ws_node_name3 & "[1]/*")

For i4 = 0 To oNodes4.length - 1
Set oNode4 = oNodes4.nextNode
If Not (oNode4 Is Nothing) Then
sName = oNode4.nodeName
sData = oNode4.xml
End If
Next


End Sub

====================

Alguien podria ayudarme ?
Gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:00.