Friday, 15 January 2010

Xpath - how to get parent based on its child's attribute -



Xpath - how to get parent based on its child's attribute -

i have xml below

<root> <success /> <warnings> </warnings> <results> <result sequencenumber="1"> <resultchildone> <resultchildotwo> <elementa> <elementb importantattribute="xxx" > </elementb> </elementa> <elementa> <elementb importantattribute="yyy"> </elementb> </elementa> </resultchildotwo> </resultchildone> </result> <result sequencenumber="1"> <resultchildone> <resultchildotwo> <elementa> <elementb importantattribute="another value"> </elementb> </elementa> <elementa> <elementb importantattribute="xxx" > </elementb> </elementa> </resultchildotwo> </resultchildone> </result> </results>

i seek write xpath select result elements first kid node elementb has attribute importantattribute="xxx" , sec kid node elementb has attribute importantattribute="yyy". can help?

this works sample document:

//result[resultchildone/resultchildotwo[elementa[1]/elementb[@importantattribute='xxx']] [elementa[2]/elementb[@importantattribute='yyy']]]

xpath

No comments:

Post a Comment