Reading XML with Equal Tag (Nodes)

2

How can I read an XML file via VBScript where the file has 2 main Nodes as the following example:

XML file:

<?xml version="1.0" encoding="utf-8"?>
<!-- Primeiro details -->
<details>
  <title>aaaaaaaaa</title>
  <number>5</number>
</details>

<!-- Segundo details -->
<details>
  <title>bbbbbbbbbb</title>
  <number>6</number>
</details>

I want to get the contents of the first and second "details" capturing "title" and "number", but I can only get the first one.

Current Code:

SET objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load("E:\tmp\xml.xml")

DIM root, i

SET root = objXML.documentElement
MsgBox "Numeros de TAGs (Nodes): " & root.childNodes.length

FOR i = 0 TO (root.childNodes.length)-1
  MsgBox(root.childNodes.item(i).text)
NEXT

As it stands it will display 3 (Three) message ...
1. "Number of TAGs (Nodes): 2"
2. "aaaaaaaaa"
3. "5"

    
asked by anonymous 20.05.2015 / 17:22

1 answer

-1
SET objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = False

objXML.load("E:\tmp\xml.xml")

DIM root, i

SET root = objXML.documentElement
MsgBox "Numeros de TAGs (Nodes): " & root.childNodes.length

FOR i = 0 TO (root.childNodes.length)-1
  MsgBox(root.childNodes.item(i).selectSingleNode("title").nodeTypedValue)
NEXT

Would that be?

root.childNodes.item (i) .selectSingleNode ("title"). nodeTypedValue root.childNodes.item (i) .selectSingleNode ("number"). nodeTypedValue

    
06.11.2018 / 20:19