2

Is there a way with JavaScript to loop through all attributes of a given xml node?

I am hoping that there's a simple method that doesn't involve calling a library (jQuery or other).

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Christophe
  • 27,383
  • 28
  • 97
  • 140
  • 4
    See related: http://stackoverflow.com/questions/828311/how-to-iterate-through-all-attributes-in-an-html-element – Mrchief Aug 10 '11 at 21:37

1 Answers1

1

You can use the attributes collection.

for (var i=0; i<node.attributes.length; i++)
{
    var attrib = node.attributes[i];
}
gilly3
  • 87,962
  • 25
  • 144
  • 176