i know if want find a nodes can use root.xpath('.//a'). how should if want iterate on 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>
there possible ways, here of them.
using union operator (|) :
.//a | .//b using or operator allow multiple possible self::element, mentioned in comment :
.//*[self::a or self::b] or mix of 2 :
.//*[self::a | self::b]
Comments
Post a Comment