Created
January 31, 2023 01:43
-
-
Save aih/ec6705f4c776335de9a08dd2c3f4500b to your computer and use it in GitHub Desktop.
Copilot-generated algorithm to diff content of two XML files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import etree | |
from lxml.etree import XMLParser | |
from lxml import html | |
from lxml.html.diff import htmldiff | |
def diffXMLContent(file1, file2): | |
parser = XMLParser(remove_blank_text=True) | |
tree1 = etree.parse(file1, parser) | |
tree2 = etree.parse(file2, parser) | |
text1 = tree1.xpath('//text()') | |
text2 = tree2.xpath('//text()') | |
return htmldiff(text1, text2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment