2
how can I read an XML file via Vbscript where the file has 2 main tags (Nodes) equal as the example below:
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 the "title" and the "number", but I can only get from the first.
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. "Tag Numbers (Nodes): 2"
2. "aaaaaaaaaaaaa"
3. "5"
You could put the code you have so far?
– carlosfigueira
@carlosfigueira updated the post with the current code, but the XML file can only have one Details, because if there are two of the error.
– Roberto Valentim
you can edit the contents of the file: it is usually used like this (
<details><detail id="1"></detail><detail id="2"></detail><detail id="X"></detail>
). So, you know you have a list of details and can read each one without problems.– mend3
@mend3 unfortunately not da, as xml files are generated from another software, also thought to do this... another however is the amount of files to be changed that is immense.
– Roberto Valentim