I would like to know if there is shorter approach to selecting a list of nodes ignoring the ones that have an attribute value specified in a list
Working example:
/item[not(@uid='id1') and not(@uid='id2')]
Desired alternative:
/item[not(@uid in('id1','id2'))]
You can either use regex - if your xpath implementation supports it - or write
/item[not(@uid='id1' or @uid='id2')]
which might be a bit shorter.
If the list of attribute names is very long, the following is a good way to handle this situation:
//item[not(contains('|attr1|attr2|attr3|attr4|attr5|attr6|attrN|', concat('|', @uid, '|') ) )]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With