xml - Select a node that has a specific attribute value in javascript -
in xml :
<elements> <product id="1"> <brand>xxxxxxx</brand> <dci>xxxxx</dci> <therapeutic_area>xxxxxx</therapeutic_area> </product> <product id="2"> <brand>xxxxxx</brand> <dci>xxxx</dci> <therapeutic_area>xxxx</therapeutic_area> </product> <product id="3"> <brand>xxx</brand> <dci>xxxx</dci> <therapeutic_area>xxxxx</therapeutic_area> </product>
i need select node has specific attribute value. instance 2
i tried not work:
alert(xmldoc.getelementsbytagname("product")[0].getattributenode("2"));
thanks in advance help
try
var list=xmldoc.getelementsbytagname("product"); (i=0;i<list.length;i++) { if(list[i].getattribute("id")==2){ // found node } }
Comments
Post a Comment