What is the precise childnode-path to loop xml-file?

<%
for i = 0 to xmlcontents.ChildNodes.attributes.length - 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</position>      
                <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</position>
        </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("Microsoft.FreeThreadedXMLDOM")

if request.QueryString("delete") <> "" then
objXML.Load(xmlpath)
set remove = _
objXML.childnodes(0).childnodes(1).childnodes(request.QueryString("delete"))
objXML.childnodes(0).childnodes(1).removeChild(remove)
objXML.save(xmlpath)
end if

objXML.Load(xmlpath)
set xmlcontents = objXML.DocumentElement.selectSingleNode("positions")
%>

<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.attributes.length - 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).attributes.id %></td>
      <td><%= xmlcontent.ChildNodes(i).attributes.xPosition %></td>
      <td><%= xmlcontent.ChildNodes(i).attributes.yPosition %></td>
      <td><%= xmlcontent.ChildNodes(i).attributes.xWidth %></td>
      <td><%= xmlcontent.ChildNodes(i).attributes.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.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 %>

Open in new window

SimonAdrianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
>> No VB-script solution or any other ways
If you don't want vbscript, then what is this?

for i = 0 to xmlcontents.ChildNodes.length - 1
...
next
0
Anthony PerkinsCommented:
>>No VB-script solution or any other ways.<<
Than why post it here?  Perhaps you should post it here: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/#browseZones
0
SimonAdrianAuthor Commented:
Sorry, I just want to stress, that I  want the path changed, not the entire script.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

hieloCommented:
Here you go:
<%@language="vbscript"%>
<%
Dim xmlPath
xmlPath = Server.MapPath("map.xml")
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
'objXMLDoc.load( Server.MapPath("map.xml"))
 
if request.QueryString("delete") <> "" then
	objXML.Load(xmlpath)
	set remove = _
	objXML.documentElement.childnodes(0).childnodes(request.QueryString("delete"))
	objXML.documentElement.childnodes(0).removeChild(remove)
	objXML.save(xmlpath)
end if
objXML.Load(xmlpath)
 
 
set xmlcontents = objXML.documentElement.selectSingleNode("positions")
Response.Write xmlcontents.childNodes.length
 
'Response.End
Dim limit
limit = xmlcontents.childNodes.length - 1
%>
<table border='1'>
<%
for i = 0 to  limit
	set xmlcontent = xmlcontents.ChildNodes.item(i).attributes
%>
    <tr> 
      <td><a href="editcontent.asp?id=<%= i+1%>">Edit</a> - <a href="?delete=<%= i%>">Delete</a></td>
      <td><%= xmlcontent(0).text%></td>
      <td><%= xmlcontent(1).text%></td>
      <td><%= xmlcontent(2).text%></td>
      <td><%= xmlcontent(3).text%></td>
      <td><%= xmlcontent(4).text%></td>
    </tr>
    <% next %>
</table>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
Update: You don't need this:
Response.Write xmlcontents.childNodes.length

(I used it for debugging)
0
SimonAdrianAuthor Commented:
Im gratefull, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.