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
  • 43,322
  • 6
  • 62
  • 109
Christophe
  • 25,975
  • 25
  • 91
  • 136
  • 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
  • 83,908
  • 25
  • 139
  • 172