Skip to content

Instantly share code, notes, and snippets.

@knkumar
Created June 29, 2012 05:55
Show Gist options
  • Save knkumar/3016102 to your computer and use it in GitHub Desktop.
Save knkumar/3016102 to your computer and use it in GitHub Desktop.
javascript iterate nodeList XML
var doc = xhreq.responseText;
var parser = new DOMParser();
var link = parser.parseFromString(doc, 'text/xml');
var items = link.documentElement.childNodes;
for (var item in items) {
if(item.nodeName == 'link'){
for(var attr in item.attributes.name) {
if(item.attr.name == 'rel'){
//do something awesome
return;
}
}
}
}
@knkumar
Copy link
Author

knkumar commented Jun 29, 2012

But why is there no iterator object on a nodelist maybe we should write one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment