Classic ASP XMLUsing ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I want to loop trough this xml to read id and action (for example 'uitleg2' and 'uitleg') The xml can go a lot of levels deep. So I need a function to loop through the xml. This is what I have but, of course, does not work.
Code:
dim xml
Response.Buffer = True
Set xml = server.createobject("Microsoft.xmldom")
xml.async = false
xml.load (Server.MapPath("test.xml"))
openXml()
function openXml()
dim objChildNodes, strNode
set objNode = XML.selectNodes("wizard/action")
For i = 0 To (objNode.length - 1)
Set objChildNodes = objNode(i)
Readnode(objChildNodes)
Next
End function
Function readNode(strNode2)
on error resume next
response.write(strNode2.nodename & " " & strNode2.text & " " & strNode2.getAttribute("id") & "<br>")
on error goto 0
If strNode2.hasChildNodes() then
set oNodeList2 = strNode2.childnodes
For Each node2 In oNodeList2
Readnode(node2)
Next
End if
End function
I do want to have the id values back so:
uitleg2 > uitleg
uitleg1 > uitleg
Ifelseactivity1 > ifelseactivity
ifelsebranchactivity1 > ifelsebranchactivity
uitleg3 > uitleg
ifelsebranchactivity2 > ifelsebranchactivity
The i need to know the 'depth' of the children (is there a property for that?). I need to know that uitleg3 is a child of ifelsebranchactivity1 which is a child of ifelsebranchactivity
I also need to now the level of the children so that I know that IfElseBranchActivity1
and IfElseBranchActivity2 are children of IfElseActivity1 and Uitleg3 is a child of IfElseBranchActivity1.
In the loop I want to create a dynamic form. With a case statement. So 'uitleg' means a textbox. With the value 'Uitleg2' I read in the database to have the initial value of the textbox.
'IfElseActivity' will be a dropdown. the IfElseBranchActivity's is the number of options in the dropdown and so on. So your example is ok. How do I achive this?
It would have helped *A LOT* if you had simply SHOWN the <form> you want to produce from that HTML.
See, what you say *still* doesn't make sense.
FIne. Now what is the *NAME* of the textbox???
Is it supposed to be
Code:
<input name="uitleg" value="Uitleg2" />
or did you miswrite that??? Did you mean "name" when you
The name for the textbox I will read from the database but the result will be something like this.
Code:
<input name="fromDatabase" value="Uitleg2" />
It is very complicated and I can't show you much as I'm still prototyping.
Can't you explain me how I can read the depth en how the text property only gives me the first "word".
Sorry that I can't make it very clear.
I read the xml > this gives me "uitleg2" > with the information from the database and the xml file I contruct a formfield.
Bottemline is: How do I get the information from the xml?
The number at the front is the "depth" (level number) where the match was found.
The "path" then shows:
/nodeTagName[id=nodeId]
and, at the end, the text of the node, when found.
You should be able to remove the parts of that which you don't care about to get what you need.