Q:

python lxml how to find multiple markup?

I know if I want to find all a nodes I can use root.xpath('.//a'). But how should I do if I want to iterate over all a or b nodes (depth first search)?
<?xml version="1.0"?>
<root>
    <x><a>one</a></x>
    <x><x><b>three</b></x></x>
    <b>three</b>
</root> 

A:

There are some possible ways, here are some of them.
using union operator (|) :
.//a | .//b

using or operator to allow multiple possible self::element, as mentioned in the comment :
.//*[self::a or self::b]

or mix of the two :
.//*[self::a | self::b]

