Compare two xml files while ignoring some xml tags | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Compare two xml files while ignoring some xml tags

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-11-2013
Shaishav Shah Shaishav Shah is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 21 January 2014, 6:53 AM EST
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Compare two xml files while ignoring some xml tags

I've got two different files and want to compare them.

File 1 :

HTML Code:
<response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record id="38,557"><columns><column><name>orge SMS call NO</name><value>&lt;![CDATA[message_id-13]]&gt;</value></column><column><name>username</name><value>&lt;![CDATA[ci_user-13]]&gt;</value></column><column><name>SENT TO</name><value>&lt;![CDATA[to_address-13]]&gt;</value></column><column><name>REPLY-TO ADDRESS</name><value>&lt;![CDATA[reply_to_address-13]]&gt;</value></column><column><name>TIME SENT</name><value>&lt;![CDATA[2010-08-08 21:47:40.274 UTC]]&gt;</value></column><column><name>TIME CLOSED</name><value>&lt;![CDATA[2010-08-08 22:08:16.216 UTC]]&gt;</value></column><column><name>STATE</name><value>&lt;![CDATA[state-13]]&gt;</value></column><column><name>REFUNDED</name><value>&lt;![CDATA[no]]&gt;</value></column><column><name>CLIENT IP</name><value>&lt;![CDATA[87.200.199.226]]&gt;</value></column><column><name>CURRENCY</name><value>&lt;![CDATA[key_ccy]]&gt;</value></column><column><name>PRICE</name><value>&lt;![CDATA[001.107]]&gt;</value></column></columns></record></recordSet></response>
File 2 :

HTML Code:
<response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record id="38,557"><columns><column><name>orge SMS call NO</name><value>&lt;![CDATA[message_id-13]]&gt;</value></column><column><name>username</name><value>&lt;![CDATA[ci_user-13]]&gt;</value></column><column><name>SENT TO</name><value>&lt;![CDATA[to_address-13]]&gt;</value></column><column><name>REPLY-TO ADDRESS</name><value>&lt;![CDATA[reply_to_address-13]]&gt;</value></column><column><name>TIME SENT</name><value>&lt;![CDATA[2010-08-08 21:47:40.274 UTC]]&gt;</value></column><column><name>TIME CLOSED</name><value>&lt;![CDATA[2010-08-08 22:08:16.216 UTC]]&gt;</value></column><column><name>STATE</name><value>&lt;![CDATA[state-13]]&gt;</value></column><column><name>REFUNDED</name><value>&lt;![CDATA[no]]&gt;</value></column><column><name>CLIENT IP</name><value>&lt;![CDATA[87.200.199.226]]&gt;</value></column><column><name>CURRENCY</name><value>&lt;![CDATA[key_ccy]]&gt;</value></column><column><name>PRICE</name><value>&lt;![CDATA[001.107]]&gt;</value></column></columns></record></recordSet></response>

Now I am comparing this two files but want to ignore specific tags e.g. <ticketId="944"> and <totalCount="1">

How can i copmare two files while ignoring above values ?
Sponsored Links
    #2  
Old 02-11-2013
sizemj sizemj is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 15 February 2013, 9:03 AM EST
Location: Louisville, KY USA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
I would use "diff"
UNIX man pages : diff ()
Sponsored Links
    #3  
Old 02-12-2013
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
who?
 
Join Date: Dec 2003
Last Activity: 30 July 2014, 5:10 AM EDT
Location: /dev/ph
Posts: 4,773
Thanks: 59
Thanked 423 Times in 392 Posts
There is no free tool out there that will allow you to compare two XML files whilst selectively ignoring some tags.

Simpliest approach would be turn both XML files into canonical XML files, and compare the results using diff.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find un-closed tags in XML files unme Shell Programming and Scripting 3 01-04-2013 04:53 AM
How to add the multiple lines of xml tags before a particular xml tag in a file mjavalkar Shell Programming and Scripting 0 06-25-2012 04:54 PM
Shell Script to compare xml files and print output to a file kanthrajgowda UNIX for Advanced & Expert Users 2 03-28-2011 11:23 AM
Renaming files with strings from xml tags degoor Windows & DOS: Issues & Discussions 3 12-31-2009 06:00 AM
How to remove xml namespace from xml file using shell script? Gary1978 Shell Programming and Scripting 10 10-26-2008 09:32 PM



All times are GMT -4. The time now is 03:14 PM.