graham o'donnel
graham o'donnel

Reputation: 395

Select xml node by attribute in javascript

I need to read an xml node in javascript, just if a certain attr has a specific value. Is there any way without using a loop? I mean something like:

x = xml.getElementsByTagName("someXmlTag")[someAttr=someValue];

Upvotes: 1

Views: 1740

Answers (1)

Jaromanda X
Jaromanda X

Reputation: 1

This works in firefox

var x = xml.querySelector('someXmlTag[someAttr=someValue]');

YMMV with other browsers

Upvotes: 2

Related Questions