xml - XPath to get node name based on existence of child node -


i have following nodes:

<resource>     <datafield1>          <label>...</label>          <alert>...</alert>      </datafield1>      <datafield2>          <label>...</label>      </datafield2>      <datafield3>         <label>...</label>         <alert>...</alert>      </datafield3> </resource> 

and show name of 1st , 3rd node because exists child node "alert".

datafield1 datafield3 

with following xpath can show nodes:

 //resource/*[alert] 

result:

<datafield1>     <label>...</label>     <alert>...</alert> </datafield1> <datafield3>     <label>...</label>     <alert>...</alert> </datafield3> 

but not want.

you need add label:

//resource/*[alert]/label 

Comments

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -