using Xpath to look for one or another element

I know how to use finditer to select one type of element, as in speech.iterfind('.//tei:w', namespaces = {'tei':'http://www.tei-c.org/ns/1.0'}) which selects all the <w> descendants of the parent element. But what if I want to find <w> OR <c> elements. As I understand from a posting in stackoverflow, iterfind('.//tei:w |.//tei:c',namespaces = {'tei':'http://www.tei-c.org/ns/1.0'}) should do the trick in regular expression mode. But it doesn't seem to work. Am I doing something wrong or have I hit a limit of the program?

Martin Mueller schrieb am 11.12.2014 um 05:25:
I know how to use finditer to select one type of element, as in
speech.iterfind('.//tei:w', namespaces = {'tei':'http://www.tei-c.org/ns/1.0'})
which selects all the <w> descendants of the parent element. But what if I want to find <w> OR <c> elements. As I understand from a posting in stackoverflow,
iterfind('.//tei:w |.//tei:c',namespaces = {'tei':'http://www.tei-c.org/ns/1.0'})
should do the trick in regular expression mode. But it doesn't seem to work. Am I doing something wrong or have I hit a limit of the program?
That's XPath functionality that is not currently available in ElementPath (i.e. the .find*() methods). Use speech.xpath() instead, or, in the simple case above, use speech.iter("{http://www.tei-c.org/ns/1.0}w", "{http://www.tei-c.org/ns/1.0}c") which is also faster. Stefan
participants (2)
-
Martin Mueller
-
Stefan Behnel