For example, my XML code is:
<part>
<name>qwe</name>
<ir>
<d>yes</d>
<scalar>
<left>31</left>
<right>0</right>
</scalar>
</ir>
</part>
<part>
<name>qaz</name>
<ir>
<d>yes</d>
<scalar>
<left>1</left>
<right>0</right>
</scalar>
</ir>
</part>
<part>
<name>asd</name>
<ir>
<d>yes</d>
<drive>
<default>1</default>
</drive>
</ir>
</part>
<part>
<name>zxc</name>
<ir>
<d>no</d>
<scalar>
<left>3</left>
<right>0</right>
</scalar>
<drive>
<default>0</default>
</drive>
</ir>
</part>
I want to extract all the names which don’t have a node default, i.e. the output should be qwe, qaz in this example. You have to check the value of default value if it is 0 or 1 and print that asd has default 0 and zzxc has default 1. if it doesn’t exist print that qwe has no default and qaz has no default value.
If the default is always in
ir/drive, you can just use the following XPath expression: