# ASP - Need help creat loop

**URL:** <https://forum.kirupa.com/t/asp-need-help-creat-loop/212101>\
**Category:** programming\
**Created:** [January 8, 2007, 3:32pm UTC](https://forum.kirupa.com/t/asp-need-help-creat-loop/212101 "2007-01-08T15:32:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acc](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@acc](https://forum.kirupa.com/u/acc)\
**Post date:** [January 8, 2007, 3:32pm UTC](https://forum.kirupa.com/t/asp-need-help-creat-loop/212101/1 "2007-01-08T15:32:04Z")

</div>

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)

```auto

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

```auto

  
      If cat = "1" Then

```

I tried this code

```auto

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.
