Table of Contents

XPath dnevnik

An XPath recipe list. See also Bibliographic XPath Queries and BaseX Adventures.

1. Find attributes by ends of their value strings

@ana[ends-with(.,”exempla”)]

2. Find a specific element and all of its descendants of the same kind

seg[ancestor-or-self::seg[@xml:id[. eq 'E6.9.4']]]

3. Find all elements with attributes that contain a specific string

@ana[contains(.,”MARK”)]

4. Retrieve all elements with specific attributes preceded by siblings with specific attributes

seg[@ana[. eq 'MARK']][preceding-sibling::seg[@ana[. eq 'NORMAL']]]

5. Retrieve all elements with specific attributes immediately preceded by a sibling with specific attributes

seg[@ana[. eq 'PLANA']][preceding-sibling::seg[1][@ana[contains(.,'tekst')]]]

6. Find all elements with odd / even numeric values in attributes

anchor[number(@n) mod 2 = 1]