# Examples of Patterns

The table below gives some examples of patterns, and explains their meaning:

Pattern | Meaning
XXX | Matches any element whose name (tag) is XXX
* | Matches any element
XXX/YYY | Matches any YYY element whose parent is an XXX
XXX//YYY | Matches any YYY element that has an ancestor named XXX
/*/XXX | Matches any XXX element that is immediately below the top-level element in the document
*[@NAME] | Matches any element with a NAME attribute
SECTION/PARA[1] | Matches any PARA element that is the first PARA child of a SECTION element
SECTION[TITLE="Contents"] | Matches any SECTION element whose first TITLE child element has the value "Contents"
A/TITLE | B/TITLE | C/TITLE | Matches any TITLE element whose parent is of type A or B or C (Note that this cannot be written "(A|B|C)/TITLE", although that is a valid node-set expression.)
/BOOK//* | Matches any element in a document provided the top-level element in the document is named "BOOK"
A/text() | Matches the character content of an A element
A/@* | Matches any attribute of an A element

Expand |