find xml element by attribute

Posted by Moudy on Stack Overflow See other posts from Stack Overflow or by Moudy
Published on 2010-06-11T15:56:56Z Indexed on 2010/06/11 16:02 UTC
Read the original article Hit count: 270

Filed under:
|
|
|

Using JQuery or Javascript how would I return 'Mary Boone' from the xml below starting out with the show 'id' attribute of '2'?

I'm thinking something along the lines of -

var result = xml.getElementByAttribute("2").gallery.text();

the XML:

<shows>
    <show id="1">
        <artist>Andreas Gursky</artist>
        <gallery>Matthew Marks</gallery>
        <medium>photography</medium>
    </show>
<show id="2">
        <artist>Eric Fischl</artist>
        <gallery>Mary Boone</gallery>
        <medium>painting</medium>
    </show>
</shows>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery