[BangPypers] Regarding 2 XML Files Comparision using Python

Ruchir Shukla ruchiryshukla at gmail.com
Thu Jun 4 11:37:45 CEST 2009


import difflib
f=open('text1.txt','rb')
text1=f.read()
f.close()
f=open('text2.txt','rb')
text2=f.read()
f.close()
#print text1
#print text2
text1_lines = text1.splitlines(1)
text2_lines = text2.splitlines(1)
d = difflib.HtmlDiff()

diff = d.make_file(text1_lines, text2_lines)
print diff


To find difference this program and  *"difflib"* library can help you
HtmlDiff will return the HTML format of the comparison.

if u are looking for output in plain text format then following can help
you.

import difflib
d = difflib.Differ()
diff = d.compare(text1_lines, text2_lines)

On Thu, Jun 4, 2009 at 2:59 PM, testing123 test <swtest123 at gmail.com> wrote:

> Hi all,
>        I am prasad.I need a help to write a python script to compare two
> XML Files.Is there any tutorial.Should we include any library?Please help me
> How to start?
>
> Rgds,
> Prasad
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>


-- 
------------------------------
Thanking You
Ruchir Shukla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20090604/f8905c73/attachment.htm>


More information about the BangPypers mailing list