SimonAdrian
asked on
What is the precise childnode-path to loop xml-file?
<%
for i = 0 to xmlcontents.ChildNodes.att ributes.le ngth - 1
set xmlcontent = xmlcontents.ChildNodes(i). attributes %>
this code is my attempt to convert another fine working looping to this need (see attached snippet of the original code).
I want to present some xml-attributes as records, but I cant quite figure out how to loop through the xml-file, that looks like this:
<map>
<positions>
<position id="1" xPosition="80" yPosition="80" xWidth="120" yHeight="60">Bruxelles</po sition>
<position id="2" xPosition="10" yPosition="60" xWidth="100" yHeight="90">New York</position>
<position id="3" xPosition="100" yPosition="180" xWidth="200" yHeight="20">Los Angeles</position>
<position id="4" xPosition="150" yPosition="150" xWidth="120" yHeight="30">Singapore</po sition>
</positions>
</map>
I have tried to change a code that was doing the job with a xml-file that was formatted with nodeelements ( see attached snippet).
The purpose is to present records which can be edited and deleted.
<%
dim objXML
set objXML = server.CreateObject("Micro soft.FreeT hreadedXML DOM")
if request.QueryString("delet e") <> "" then
objXML.Load(xmlpath)
set remove = _
objXML.childnodes(0).child nodes(1).c hildnodes( request.Qu eryString( "delete"))
objXML.childnodes(0).child nodes(1).r emoveChild (remove)
objXML.save(xmlpath)
end if
objXML.Load(xmlpath)
set xmlcontents = objXML.DocumentElement.sel ectSingleN ode("posit ions")
%>
<html>
<body>
<table width="180">
<tr>
<th width="80">Options</th>
<th width="20">id</th>
<th width="20">xPosition</th>
<th width="20">yPosition</th>
<th width="20">xWidth</th>
<th width="20">yHeight</th>
</tr>
'The solution I want is solving the code below.
<%
for i = 0 to xmlcontents.ChildNodes.att ributes.le ngth - 1
set xmlcontent = xmlcontents.ChildNodes(i). attributes %>
<tr>
<td><a href="editcontent.asp?id=< %= i+1%>">Edit</a> - <a href="?delete=<%= i%>">Delete</a></td>
<td><%= xmlcontent.ChildNodes(i).a ttributes. id %></td>
<td><%= xmlcontent.ChildNodes(i).a ttributes. xPosition %></td>
<td><%= xmlcontent.ChildNodes(i).a ttributes. yPosition %></td>
<td><%= xmlcontent.ChildNodes(i).a ttributes. xWidth %></td>
<td><%= xmlcontent.ChildNodes(i).a ttributes. yWidth %></td>
</tr>
<% next %>
</table>
</body>
</html>
I have to stress that Im not interested in doing it any other way. I want the rest of the code to be precisely as it is. No VB-script solution or any other ways.
Just make the topcode usable to the script as the codesnippet does to its xml-file.
for i = 0 to xmlcontents.ChildNodes.att
set xmlcontent = xmlcontents.ChildNodes(i).
this code is my attempt to convert another fine working looping to this need (see attached snippet of the original code).
I want to present some xml-attributes as records, but I cant quite figure out how to loop through the xml-file, that looks like this:
<map>
<positions>
<position id="1" xPosition="80" yPosition="80" xWidth="120" yHeight="60">Bruxelles</po
<position id="2" xPosition="10" yPosition="60" xWidth="100" yHeight="90">New York</position>
<position id="3" xPosition="100" yPosition="180" xWidth="200" yHeight="20">Los Angeles</position>
<position id="4" xPosition="150" yPosition="150" xWidth="120" yHeight="30">Singapore</po
</positions>
</map>
I have tried to change a code that was doing the job with a xml-file that was formatted with nodeelements ( see attached snippet).
The purpose is to present records which can be edited and deleted.
<%
dim objXML
set objXML = server.CreateObject("Micro
if request.QueryString("delet
objXML.Load(xmlpath)
set remove = _
objXML.childnodes(0).child
objXML.childnodes(0).child
objXML.save(xmlpath)
end if
objXML.Load(xmlpath)
set xmlcontents = objXML.DocumentElement.sel
%>
<html>
<body>
<table width="180">
<tr>
<th width="80">Options</th>
<th width="20">id</th>
<th width="20">xPosition</th>
<th width="20">yPosition</th>
<th width="20">xWidth</th>
<th width="20">yHeight</th>
</tr>
'The solution I want is solving the code below.
<%
for i = 0 to xmlcontents.ChildNodes.att
set xmlcontent = xmlcontents.ChildNodes(i).
<tr>
<td><a href="editcontent.asp?id=<
<td><%= xmlcontent.ChildNodes(i).a
<td><%= xmlcontent.ChildNodes(i).a
<td><%= xmlcontent.ChildNodes(i).a
<td><%= xmlcontent.ChildNodes(i).a
<td><%= xmlcontent.ChildNodes(i).a
</tr>
<% next %>
</table>
</body>
</html>
I have to stress that Im not interested in doing it any other way. I want the rest of the code to be precisely as it is. No VB-script solution or any other ways.
Just make the topcode usable to the script as the codesnippet does to its xml-file.
<%
for i = 0 to xmlcontents.ChildNodes.length - 1
set xmlcontent = xmlcontents.ChildNodes.item(i)
%>
<tr>
<td><a href="editcontent.asp?id=<%= i+1%>">Edit</a> - <a href="?delete=<%= i%>">Delete</a></td>
<td><%= xmlcontent.ChildNodes.item(1).text%></td>
<td><%= xmlcontent.ChildNodes.item(2).text%></td>
<td><%= xmlcontent.ChildNodes.item(3).text%></td>
<td><%= xmlcontent.ChildNodes.item(4).text%></td>
<td><%= xmlcontent.ChildNodes.item(5).text%></td>
</tr>
<% next %>
>>No VB-script solution or any other ways.<<
Than why post it here? Perhaps you should post it here: https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/#browseZones
Than why post it here? Perhaps you should post it here: https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/#browseZones
ASKER
Sorry, I just want to stress, that I want the path changed, not the entire script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Update: You don't need this:
Response.Write xmlcontents.childNodes.len gth
(I used it for debugging)
Response.Write xmlcontents.childNodes.len
(I used it for debugging)
ASKER
Im gratefull, thanks.
If you don't want vbscript, then what is this?
for i = 0 to xmlcontents.ChildNodes.len
...
next