I had to do some fishing around to figure this much out. Hope it helps. from input import * # From the xmldiff directory from fmes import * # From the xmldiff directory from format import * # From the xmldiff directory from StringIO import *
# Build your original tree text1 = '<point><x>1</x><y>2</y><z>3</z></point>' stream1 = StringIO(text) tree1 = tree_from_stream(stream) # Build your modified tree text2 = '<point><x>2</x><y>2</y><z>3</z></point>' stream2 = StringIO(text2) tree2 = tree_from_stream(stream2) # Compare the trees formatter = InternalPrinter() corrector = FmesCorrector(formatter) corrector.process_trees(tree, tree2) ## OUTPUT: ## Instructions for modifying original to modified # [rename, /point[1]/y[1], x] # [insert-after, /point[1]/x[2], # <y> # 2 # </y> # ] # [remove, /point[1]/x[1]] > On Wednesday, February 03, 2010 1:38 AM sWrath swrath wrote: > Hi , > > I am pretty new to python , and reading up on it. > > Basically I am trying to compare xml files . I know difflib have it > but it does not work out as expected. I was looking at xmldiff , > unfortunately I am not able to find documentation how to call it from > python. Anyone knows a link or doc to it as I have been looking high > and low for few days? > > lastly , is there a py (or algorithm) where it behaves exactly like > diff ? Greatly appreciated. > > Thanks > john >> On Wednesday, February 03, 2010 3:34 PM Terry Reedy wrote: >> On 2/3/2010 1:38 AM, sWrath swrath wrote: >> >> When asking such a question, it is good to explain what sort of thing, >> in this case, 'xmldiff' is and where it is is from. Let us assume you >> meant xmldiff from >> >> http://www.logilab.org/859 >> >> It says it is a python tool that can "be used be used as a library or as >> a command line tool." It includes a README file. Have you read that? >> That says "USAGE ... Read the HELP.txt file.". Have you read *that*? >> HELP.txt seems to focus on command line usage. I would start with that. >> To use it as a library (via import ...), you might have to look at the >> source code as I did not see importing covered in my quick look at that >> file. >> >> Terry Jan Reedy >> Submitted via EggHeadCafe - Software Developer Portal of Choice >> FireAndForget Asynchronous Utility Class for SQL Server Inserts and Updates >> http://www.eggheadcafe.com/tutorials/aspnet/7a22d9a4-59fc-40b0-8337-75c76f14fb3b/fireandforget-asynchronous-utility-class-for-sql-server-inserts-and-updates.aspx -- http://mail.python.org/mailman/listinfo/python-list