Is there a way to do 'not equal to' in elementtree xpath expression?

Viewed 101

Looking for a way to do 'not equal to' in ElementTree with an Xpath expression. Everything i've tried ends up with "invalid predicate" SyntaxError. Has anyone had any luck with this?

Here's an example of what i'm trying to do:

worker.findall("ws:Related_Person[ws:Operation!='REMOVE']", ns)

That produces the SyntaxError, but if i use:

worker.findall("ws:Related_Person[ws:Operation='REMOVE']", ns)

...it works fine. Unfortunately i need 'not equals' in this situation, as there are several good values and only 1 value i want to ignore.

Is this possible with ElementTree or do i have to switch libraries to lxml for basic not equals comparisons? The data source changed their output on me and i'd rather not have to rewrite the codebase using another xml library just to handle a != if i can avoid it.

0 Answers
Related