I have those two RxPaths which I need to be written in one expresion:
/td[2]/a[1]/tag[1]
and
/td[2]/a[1]
So basically I need to select path with ‘tag’ element if exists, if not than to select ‘a’ element.
something like:
if exist /td[2]/a[1]/tag[1] select /td[2]/a[1]/tag[1]
else select /td[2]/a[1]
Those elements need to have innertext attribute with some value in them, so I tried:
/td[2]/descendant::node()[@innertext!='']
but it won’t work…
Also those elements are at the bottom of hierarchy so if is there any way to just select first element at lowest level.
I managed to solve this with an regex at the end of my Xpath expression.
/dom/body/div[@id='isc_0']/div/div[@id='isc_B']/div[@id='isc_C']/div[@id='isc_10']/div/div/iframe/body/table/tbody/tr/td[1]/a[@innertext='any uri item']/../../td[2]/*[@innertext~'[^ ]+']
Sorry for misunderstanding with problem…
Regards,
Vajda Vladimir
I highly doubt that the top element of the document is a
td. Don’t use/td— it means you want to select the top element of the document and this top element must be atd.Also,
/td[2]never selects anything, because a (wellformed) XML document has exactly one top element.Use:
Use:
This is not clear. Please, clarify.
All “leaf” elements can be selected using the following XPath expression:
The elements selected don’t have any children-elements, but may have other children (such as text-nodes, PIs, comments) and attributes.