Replace Tag Content Assertion
The Replace Tag Content assertion provides search-and-replace functionality for content within tags, in HTML or XML files (even where the HTML/XML is not properly formed).
Replace Tag Contentassertion provides search-and-replace functionality for content within tags, in HTML or XML files (even where the HTML/XML is not properly formed).
This assertion is especially useful in reverse web proxy scenarios, where the Gateway needs to manipulate HTML content in a route response before it is returned to the client.
The Evaluate Regular Expression Assertion can also be used to search and replace content in the response, but it is difficult to create regular expressions that search and modify only select areas of the HTML code.
Example use case:Some HTML tags (anchor, script, etc.) may contain content or attributes that references the web application host which is unknown to the client. Use the Replace Tag Content assertion to change the references to the Gateway host, which is serving as a reverse proxy to the web application.
To learn about selecting the target message for this assertion, see Selecting a Target Message.
Using the Assertion
- Do one of the following:
- To add the assertion to the Policy Development window, see Add an Assertion.
- To change the configuration of an existing assertion, proceed to step 2 below.
- When adding the assertion, the Replace Tag Content Properties automatically appear; when modifying the assertion, right-click<target>:Replace...Replace Tag Content Propertiesor double-click the assertion in the policy window. The assertion properties are displayed.
- Configure the properties as follows:SettingDescriptionSearch ForEnter the string to search for. You may reference context variables.By default, the search is case sensitive. To make it case insensitive, select theIgnore Casecheck box.Replace WithEnter the replacement text. You may reference context variables.Within TagsSpecify the tag(s) to search (case insensitive). Separate multiple tags with commas. You may reference context variables.
- Click [OK] when done.