XPath Query Examples for Reports
Common XPath Operators, Expressions, and Functions
|||Contains a filter string|
|@||Indicates an attribute instead of an element|
|*||Wildcard returns all values|
|=||Equal to |
|!=||Not Equal to |
|And||Both conditions must be true |
|Or||One of the multiple conditions must be true
|contains()||Value must contain text
|not()||No value exists |
|Name||Page name found in page properties; case-sensitive.
|ID||xID found in page properties; case-sensitive.
|Schema||Page schema found in page properties; case-sensitive
|CheckedOut||Page checked in or out; true=checked out, falue=checked in, case-sensitive
|MarkedForPublish|| Page marked or unmarked for publish; true=marked, false=unmarked
|AssignedUser||Person to whom page is currently assigned; looks at userID rather than username
|Changed||Date and time page was last checked in with changes.
|Created||Date and time page was created.
|StartDate||Date and time page goes live.
|EndDate||Date and time page goes dead.
Simple XPath Queries
|Returns all pages assigned to user named admin.|
|Returns all pages created on date specified.|
|Returns all pages with term in name such as Products.|
|Returns results for specified ID.|
|Returns pages governed by schema, such as Details.|
|Returns results for all pages checked in.|
|Returns results for all pages checked out.|
|Returns pages changed on date provided.|
|Returns results for each page with a "go live" date/time.|
|Returns results for each page with an expiration date/time.|
|Returns all pages with an assigned start date, the date when the page(s) go live.|
|Returns all pages with an assigned end date, the date when the page(s) expire.|
XPath expressions can be combined to return more complex result sets:
/CombinedDocumentForReport/Site//Page[@ID='x5']//Page[not(@ID = /CombinedDocumentForReport/TaxonomyAssociations/Associations/A/@P)]
This XPath query references Reference.xml and TaxonomyAssociations.xml. It returns all descendant pages from a specified parent (e.g., x5) that are not tagged with taxonomy categories.
Parameterized XPath Queries
This XPath query contains two parameters:
/CombinedDocumentForReport/Site//Page[@ID='%pageId%']//Page[@ID = /CombinedDocumentForReport/PublishingTargets/PublishingTarget[@Name = '%pubtarget%']/Page/@ID]
The query references Reference.xml and publishingTargets.xml. It returns
all descendants from a parent ID that share a publishing target name. This example may
be useful if you want to find all pages assigned a particular publishing target within a
branch of the Site Tree. Once you have configured the query, you would pass in the
pubtarget parameter values from the
View Results view.
For more examples of parameterized XPath queries, see Pre-Defined Reports.