Page 1 of 1

diffFile should allow to exclude attribute values

Posted: Thu Mar 06, 2025 7:31 pm
by moisesalvarez
Hello,

The diffFIle tool allows to diff xml files and bypass certain verifications in order to focus more on node construction more than values, like excluding node text, attribute order, etc. but it is not a possible option to exclude attribute values from diff action.
Request: Add attribute values to XML diff ignore.

Thank you in advance.

Re: diffFile should allow to exclude attribute values

Posted: Fri Mar 07, 2025 12:23 pm
by teo
Hello,

You can ignore attribute values from comparison if you use the Ignore nodes by XPath option.
Consider the two sample XML files below:

personal.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<personnel>
    <person id="harris.anderson" photo="personal-images/harris.anderson.jpg">                
        <name>Harris Anderson</name>
        <email>harris.anderson@example.com</email>
    </person>
    <person id="robert.taylor" photo="personal-images/robert.taylor.jpg">
        <name>Robert Taylor</name>
        <email>robert.taylor@example.com</email>
    </person>
</personnel>
personal-new.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<personnel>
    <person id="harris.anderson.new" photo="personal-images/harris.anderson.new.jpg">                
        <name>Harris Anderson</name>
        <email>harris.anderson@example.com</email>
    </person>
    <person id="robert.taylor.new" photo="personal-images/robert.taylor.new.jpg">
        <name>Robert Taylor</name>
        <email>robert.taylor@example.com</email>
    </person>
</personnel>
In the text field enabled by checking the Ignore nodes by XPath option, fill in the following XPath expression: person/(@id | @photo)
When comparing the file pair, the provided XPath expression is taken into account and no differences are highlighted.
If you disable the Ignore nodes by XPath option and compare again, 4 differences are now highlighted because the values of the id and photo attributes are different in the 2 compared files.

Note that the Ignore nodes by XPath option is also considered when comparing directories using the Compare Directories tool.

Best regards,
Teo