Hi Thomas, Thanks for the explanation, I tried to find the documentation about XPath 1 and Xpath 2 to ensure this was not due to that, but could not find the needle in the haystack. Unfortunately, I cannot use the syntax you gave, but I found two alternatives, one being given to me by someone on the list in a private mail (Jamie): - //div//*[local-name()='p' or local-name()='l'][@n='1'] - //div//*[lself::ns:p or self::ns:l][@n='1'] Work both terribly well. In case anyone is like me, stuck with not so much ability to go the /a/a | /a/b road. Thanks a lot, Thibault On 11/26/2015 09:10 AM, Thomas Schraitle wrote:
Hi Thibault,
On Wed, 25 Nov 2015 14:22:20 +0100 Thibault Clerice <leponteineptique@gmail.com> wrote:
[...] I am trying to deal with group node condition in xpath, /ie/ xpath like
//div/(descendant::p|descendant::l)[@n='1'] //div/(ns:p|ns:l)[@n='1'] I'm not 100% sure, but I guess this XPath expression is only supported in XPath 1.0.
While this seems to be supported in xpath, ... only in XPath 2.0 if I'm not mistaken.
I cannot find a way to make it work. My hands are a little tied here because I have not that much freedom about the xpath in itself, I need to be able to support a xpath like that, or rather, I can't go with another simpler route like You can always "resolve" the group which should work:
//div/descendant::p[@n='1'] | //div/descendant::l[@n='1']
I know, it's a little bit verbose. But maybe you optimize it with some lxml and Python magic.
//div/p[@n='1'] or //div/l[@n='1'] //ns:div/ns:p[@n='1'] or //ns:div/ns:l[@n='1']
The weird thing is that the following xpath would work
(//tei:l|//tei:p)[@n='1'] This *is* supported in XPath 1.0.
[...] Hope this helps a bit.