Using Javascript to list xml node list in reverse order

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • npm
    New Member
    • Apr 2007
    • 57

    Using Javascript to list xml node list in reverse order

    Hi,
    This javascript will display my xml node list:
    Code:
    x=xmlDoc.getElementsByTagName('title');
    for (i=0;i<x.length;i++) {
    document.write(x[i].childNodes[0].nodeValue);
    document.write("<br />");
    }
    But I want to display the list in reverse order. I think it would work to put the nodes into an array and then use reverse() to switch it, but I'm not sure exactly how...
    Thanks in advance!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    why so complicated?
    Code:
    for (i = x.length; i--;)

    Comment

    Working...