Skip to content

Instantly share code, notes, and snippets.

@aih
Created January 31, 2023 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aih/ec6705f4c776335de9a08dd2c3f4500b to your computer and use it in GitHub Desktop.
Save aih/ec6705f4c776335de9a08dd2c3f4500b to your computer and use it in GitHub Desktop.
Copilot-generated algorithm to diff content of two XML files
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