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

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -