Structural search and replace examples
Examples for HTML and XML
The following examples show how you can use structural search in HTML and XML code.
Searching for XML and HTML tags, attributes, and their values
The simplest template to search for a tag is
By placing constraints on the variable
$tag$, you can specify tags that you want to find. For example, if you specify
li, you will all
Consider the following template for searching in XML and HTML:
<$tag$ $attribute$=$value$ />. For example, if you specify the text filter
$attribute$variable and the
\d+regular expression as the text filter for the
$value$variable, you can find all tags that have numeric values in the
Delete all lines that have the id attribute greater than 2
In the Search template field, we create a template that searches for all
litags with numeric values (
idattributes. We expand our search to the whole string with such values (Search target = Complete match).
We filter those lines with the following Groovy script:
d.getText().replaceAll (/"/, '').toInteger() > 2. The script reads the content of the
dvariable and returns it as a string (for example,
"1"). Then the script replaces all quotes and converts the string value to integer and compares it with
In the Replace template field, we put nothing to delete the whole string. After the search, we select Replace All to perform the replacing.