xml - Select all nodes with a child that has a certain attribute -


i'm trying select elements have child c attribute. in case first 2 elements.

<alpha>   <a id="1">     <b c="1"/>   </a>   <a id="2">     <b c="1"/>   </a>   <a id="3">     <b />   </a> </alpha> 

any thoughts on how this? i've tried following no luck:

/alpha/a/b/*[@c] //a[b/*[@c]] 

thanks in advance help!

edit: suggested consult solutions posed this question, however, problem addressed in thread different mine (involving child elements rather attributes of child elements) , haven't been able extrapolate solution problem this.

try following experssion (abbreviated syntax):

//a[*/@c] 

or can use unabbreviated syntax:

/descendant::a[child::*/attribute::c] 

Comments