I get this piece of XML from an application
<?xml version="1.0" encoding="ISO-8859-1"?>
<wizard wizardid="Workflow1">
<action id="Uitleg2">Uitleg</action>
<action id="Uitleg1">Uitleg</action>
<action id="IfElseActivity1">IfElseActivity
<action id="IfElseBranchActivity1">IfElseBranchActivity
<action id="Uitleg3">Uitleg</action>
</action>
<action id="IfElseBranchActivity2">IfElseBranchActivity</action>
</action>
</wizard>
I try to create an ASP function which reads the XML and gives me back the 'id' and the text (for example 'ifelsebranchactivity1' and 'ifelsebranchactivity'). As you can see "IfElseActivity1" has childs and one child has a subchild. This can go very deep in this xml. So a need a nice 'loop' function which checks if there is a child and so on.
Now I have this but I can't figure out how to get a nice clean function
Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("test.xml"))
Dim objChildNodes, strNode
Set objChildNodes = xml.documentElement.childNodes
For Each strNode In objChildNodes
response.write(strNode.nodename & " " & strNode.getAttribute("id") & "<br>")
If strNode.hasChildNodes() then
response.write(strNode.getAttribute("id") & " " & "has child nodes" & "<br>")
set oNodeList2 = strNode.childnodes
For Each node2 In oNodeList2
response.write(node2.nodevalue & "<br>")
If node2.hasChildNodes() then
response.write(node2.getAttribute("id") & "has child nodes" & "<br>")
end if
Next
end if
Next
Set xml = Nothing
Can someone put me in the right direction?