By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,764 Members | 1,379 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,764 IT Pros & Developers. It's quick & easy.

Need help in xml

P: n/a
i have two xml documemts of type

<job>
<jobname>test</jobname>
<jobdate>2006-12-12</jobdate>
<jobtime>12:12:12</jobtime>
<directory>
<dirname>/home/</dirname>
<file>
<name>test2</name>
<Modified time>12:12:12</Modified time>
</file>
</directory>
<directory>
<dirname>/home/test</dirname>
<file>
<name>test3</name>
<Modified time>12:12:12</Modified time>
</file>
</directory>
</job>

i have to compare 2 similar xml document and get the add, changed and
deleted files.and write it into acd.xml file.
can u help me with the python code for this. I am using SAX.

Jul 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Kirt wrote:
i have two xml documemts of type

<job>
<jobname>test</jobname>
<jobdate>2006-12-12</jobdate>
<jobtime>12:12:12</jobtime>
<directory>
<dirname>/home/</dirname>
<file>
<name>test2</name>
<Modified time>12:12:12</Modified time>
</file>
</directory>
<directory>
<dirname>/home/test</dirname>
<file>
<name>test3</name>
<Modified time>12:12:12</Modified time>
</file>
</directory>
</job>

i have to compare 2 similar xml document and get the add, changed and
deleted files.and write it into acd.xml file.
can u help me with the python code for this. I am using SAX.
Use the right tool and such problems tend to become much simpler.

http://www.logilab.org/projects/xmldiff

--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

Jul 10 '06 #2

P: n/a

Thanx Dennis Lee Bieber for ur suggestion.
After following ur suggestion i am getting 3 list after reading and
comparing the 2 xml document.
<directory>+<filename>,<modified time>
adds ['/home/moq/buc/2+add.py,200606281354\r \n',
'/home/moq/buc/1+add.py,200607031215\r \n']

Modified ['/home/moq/buc/2+mod2.py,200607111031\r \n',
'/home/moq/buc/1+mod.py,200607111031\r \n']

deletes ['/home/moq/buc/2+del.py,200606281354\r \n',
'/home/moq/buc/1+del.py,200607031215\r \n']

I have to put these in to an xml format of type
<changes>
<added>
<directory>
<dirname>/home/moq/buc/2</dirname>
<file>
<name>add.py</name>
<time>200606281354</time>
</file>
</directory>
<directory>
<dirname>/home/moq/buc/1</dirname>
<file>
<name>add</name>
<time>200607031215</time>
</file>
</directory>
</added>
</changes>

Similarly for Modified and deleted.
can someone help me with the code for this. Thanx

Jul 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.