jquery - Extracting XML elements by attribute value -
i setting little movie db website , data in xml format. have 2 xml tags stars, 1 male , 1 female. how can extract data? have tried $(this).find("star").text(); pulls both.. tried $(this).find("star").attr("male").text(); , nothing.
here xml
<movie name = "terminator 2 judgment day"> <picture>../images/t2.jpg</picture> <info> <director>james cameron</director> <star type = "male">arnold shwarzenegger</star> <star type = "female">linda hamilton</star> </info> can tell me how set can each one, separately? like
male lead: name female lead: name for example.
you try filter element attribute value :
var malestar = $(this).find("star[type='male']").text(); var femalestar = $(this).find("star[type='female']").text(); basically, pattern selector : elementname[attributename='attribute value']
Comments
Post a Comment