I need to suppress all duplicate values in an XML file and keep the final value (refer to the target file).
Kindly help, since I don’t know if I should use xslt, python, or any .NET API
Here is the source file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<artist>Bob Dylan</artist>
</cd>
<cd>
<title>Hide your heart</title>
</cd>
<cd>
<title>old_value</title>
<title>inbetween_value</title>
<title>new_value</title>
</cd>
</catalog>
The expected target file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<artist>Bob Dylan</artist>
</cd>
<cd>
<title>Hide your heart</title>
</cd>
<cd>
<title>new_value</title>
</cd>
</catalog>
There is an extremely simple (no explicit conditionals, no axes) XSLT solution:
When this transformation is applied on the provided XML document:
the wanted, correct result is produced: