![]() |
XML compare - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: XML compare (/thread-36089.html) |
XML compare - Nilis78 - Jan-15-2022 Im looking for a script what can compare xml and works simular as the compare function in notepad++. Is there a script like that? RE: XML compare - snippsat - Jan-16-2022 difflib or try some third party like xmldiff. I can do test with difflib and use rich for better look. from difflib import Differ from rich import print with open("1.xml") as f1,open("2.xml") as f2: f_1 = [i.strip() for i in f1] f_2 = [i.strip() for i in f2] diff = Differ() difference = list(diff.compare(f_1, f_2)) difference = '\n'.join(difference) print(difference) ![]() So it work fine,files used: 1.xml <app> <name>ExtendsClass</name> <type>Web</type> <url>https://python-forum.io</url> <description>Free Online forum</description> </app>2.xml <app> <name>ExtendsClass</name> <type>Web</type> <url>https://vg.no</url> <description>Online forum</description> </app> |