XPath Search in Pages
This is an advanced built-in script. Use XPath Search in Pages to search each page’s source using the provided XPath expression.
XPath Search in Pages is more powerful than the built-in Confluence search, especially when it comes to identifying hidden structural problems in your content. But that power comes at the cost of speed and efficiency. It is best only to run this built-in script on a single space. It takes about 1.5 seconds to search a space with 2,500 pages.
Run the script
Follow these steps to run the built-in script:
- Navigate to General Configuration > ScriptRunner > Built-In Scripts.
- Select XPath Search in Pages.
Enter a CQL Query to select the content you want to work with.
- CQL autocomplete is available for this field. Start typing to see possible CQL statements.
- For help with CQL, visit CQL Guide.
- Select Show Examples to see examples of CQL statements.
Enter the expression in Xpath Query.
Select Show Examples for common expressions to use with this built-in script.Select Run.
Results
Once you run the script, the results appear.
Example
Search for pages with images in a certain space
You could use this script if you require a high degree of control over the presentation of your wiki pages, and you want to make sure everything is correct. You could run the following script to see all pages with images:
- Navigate to General Configuration > ScriptRunner > Built-In Scripts.
- Select XPath Search in Pages.
- For CQL Query, enter
type = page AND space = DS
to select all of the pages in the Demonstration Space. - Enter //ac:image or select Pages with images from Show Examples for the Xpath Query.
- Select Run.
Results
The script returns the pages with images in the Demonstration Space. Each page appears as a link.