Cleaning XMLs via Regex

As an IIQ Developer, you often need to copy XML objects (e.g., Rule, Workflow) and commit them to a Version Control system like GIT. To ensure the XML is clean and free of environment-specific IDs and dates before committing, there are several methods available:

  • IIQ Console Export: Use the --clean=id,created,modified option.
  • XML Exporter: Similar cleaning options are available.

However, the most common scenario involves copy-pasting XMLs via Debug Pages, which lacks an automated way to clean environment-specific data. To address this, I have created a short RegEx expression that can be easily used in any IDE’s “Search and Replace” function to remove these attributes from the XML.

RegEx Snippet

Use the following RegEx pattern to remove created, id, and modified attributes along with any trailing spaces:

regex

Copy code

created="\d+" |id="[a-zA-Z0-9]+" |significantModified="\d+" |modified="\d+" 

Before Cleaning

Here is an example of XML before executing the regex:

Attributes Detection

Here you can see which attributes were detected by IDE as the ones which should be removed

After Cleaning Detection

Here is the same XML after executing the regex:

This approach ensures that your XML files are clean and ready for safe version control, without carrying over unnecessary environment-specific details

4 Likes

Within my IDE (IntelliJ) I am using find/replace with the following string (id|created|modified)=".*?" and replace it with nothing :wink:
Use space before the ( character to keep the also remove the space before id=“…” (created/modified).
Markdown does remove the space in this reply :frowning:

image

It is better to have the space in front of the match, as there will always be a space in front of an XML-attribute :stuck_out_tongue_winking_eye:

– Remold