PDA

View Full Version : ASP - Need help creat loop



acc
January 8th, 2007, 11:32 AM
Have an external XML file that will be used throughout the site.

I have this, part of the main script that gets the brands from a specific product category (wherein category is defined by a number)



For Each Elem In NodeList

cat=Elem.getAttribute("category")
url=Elem.selectsinglenode("link").text
brandName=Elem.selectsinglenode("name").text


If cat = "1" Then
Response.Write brandName & " / "
End If


Next
Problem is I want the value of cat to increase by 1 upto 7 in each loop



If cat = "1" Then

I tried this code



For i = 1 to 7

For Each Elem In NodeList

cat=Elem.getAttribute("category")
url=Elem.selectsinglenode("link").text
brandName=Elem.selectsinglenode("name").text


If cat = i Then
Response.Write brandName & " / "
End If


Next

Next
This is how I'd approach loops, but it does not work. Any suggestions to what would work or why this isn't working would be great.