I'm trying to grab an xml node by its attribute.
edit
I'm trying to retrieve an element by its attribute value using javascript xml instead of jquery. Is there a simple method for this?
It is really easy using jQuery. Suppose we have a string like this.
<document>
   <value type="people">
      <name>
         John
      </name>
   </value>
   <value type="vehicle">
      <name>
         Ford
      </name>
   </value>
</document>
Then
var xmlDocument = $.parseXML(str);
$(xmlDocument).find("value[type='people'] name").text()
We will get string 'John' back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With