How to simplify this Xpath expression ?
Posted
by
Stephan
on Stack Overflow
See other posts from Stack Overflow
or by Stephan
Published on 2011-01-14T12:43:06Z
Indexed on
2011/01/14
12:53 UTC
Read the original article
Hit count: 319
Hi ,
I have the following XML code :
<root>
<a><l_desc/></a>
<b><l_desc>foo</l_desc></b>
<c><l_desc>bar</l_desc></c>
</root>
I want to match the l_desc nodes with a or b nodes as parent.
For now, i use this xpath expression : //a/l_desc/.. | //b/l_desc/..
I would prefer writing something like this : //(a|b)/l_desc/..
Unfortunately, this expression is invalid.
Do you have any idea for reducing the first expression ?
Stéphan
© Stack Overflow or respective owner