SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast dlh1989's Avatar
    Join Date
    Nov 2004
    Location
    Sunshine Coast, QLD, Australia
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Count Number of Elements

    How do I count the number of elements in an element in XML in ASP. For example, I have this XML document:
    Code:
     <scoreboard> 
    <quarter q="1" hg="3" hb="2" ag="7" ab="0" period_secs="1792" period_complete="Y" /> 
    <quarter q="2" hg="6" hb="6" ag="13" ab="3" period_secs="1949" period_complete="Y" /> 
    <quarter q="3" hg="11" hb="14" ag="19" ab="6" period_secs="1990" period_complete="Y" /> 
    <quarter q="4" hg="12" hb="16" ag="21" ab="10" period_secs="1640" period_complete="Y" /> 
    </scoreboard>
    So to display 1792 i use this in ASP
    Code:
    per_sec = xml.documentElement.childNodes(0).childNodes(0).Attributes(5).text
    Now what do I write in ASP to count the number of childNodes within childNode(0) (scoreboard)?
    Last edited by dlh1989; Jun 10, 2005 at 23:11.

  2. #2
    SitePoint Enthusiast dlh1989's Avatar
    Join Date
    Nov 2004
    Location
    Sunshine Coast, QLD, Australia
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I worked out how to do it by using
    Code:
    qcounter = xml.documentElement.childNodes(0).childNodes.length
    Now I want to write the value of qcounter. How do I do that because both of these don't seem to work.
    Code:
    <% If qcounter = 1 Then Response.Write("a message") 
    End If %>
    and
    Code:
    <% If qcounter = "1" Then Response.Write("a message")
    End If %>
    .Neither worked why? and is qcounter text or a number? Thanks.
    Last edited by dlh1989; Jun 11, 2005 at 23:22.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try and write out the qcounter value and see if anything is coming through.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •