Simple XML file comparison and merging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple XML file comparison and merging
# 1  
Old 11-24-2009
Simple XML file comparison and merging

Okay, first of all, thanks to everyone who's helped me out before... I appreciate the opportunity to learn.

I have two iTunes XML files, and I simply want to compare the contents, then merge. Theoretically, this will allow me to merge two libraries, keeping playlists intact (depending on iTunes' xml interpreter and how picky it is).

As such, how would you compare two xml files and merge them?
# 2  
Old 11-24-2009
Code:
man diff and paste

# 3  
Old 11-24-2009
Diff would compare line by line, correct?

If one file is shorter than the other by no more than a line, I've already gotten a false positive and a duplicate line.
# 4  
Old 11-24-2009
If iTunes XML is anything like Rhythmbox XML, there will be attributes which include systime of when the file was imported. If I were you, I would create a hash while parsing/printing the first XML file where the key doesn't include values such as systime (or other values that will always be distinct) of the song file then loop over the second XML in a similar fashion printing only nodes where key was not found in the first.
# 5  
Old 11-25-2009
Do a web search for diffxml & patchxml
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

XML Fields comparison using awk script

Hello All, I have many zipped XMLs (example file name in tgz formate - file_rec.trx.2016-01-23.000123.exc.85sesdzd45wsds5299c8f2994f7.tgz) looks following and I need to verify two numbers, they are RecordNumber and EnrolData (only sequence number, NOT hole). for all the records, both should be... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies

2. Shell Programming and Scripting

Merging two file based on comparison of first columns

Respected Members. Hello. This is my first post in the forum. I will try to follow all the rules as prescribed by the forum. In case of non-compliance, I request you to kindly give me some more time to understand and abide by them. I am working on two files. I wish to merge the two files... (6 Replies)
Discussion started by: manojmalhotra
6 Replies

3. Shell Programming and Scripting

Merging two file based on comparison of first columns

Respected Members. Hello. This is my first post in the forum. I will try to follow all the rules as prescribed by the forum. In case of non-compliance, I request you to kindly give me some more time to understand and abide by them. I am working on two files. I wish to merge the two files... (1 Reply)
Discussion started by: manojmalhotra
1 Replies

4. Shell Programming and Scripting

Simple comparison between two lists.

I have two lists (input) Alpha and Beta. Alpha: Beta: Need the output like this: I would like to get an output like this: Alpha vs Beta | -- | a=1 | |z=3 | z=4 | Is it possible ? :cool: (5 Replies)
Discussion started by: linuxadmin
5 Replies

5. Shell Programming and Scripting

Need help with simple comparison in AWK

Hi, I'm new to AWK and I'm having problems comparing a field to a string variable. /ARTIST/ {x = $2} $1 ~ x {print $0}My code tries to find a record with the string "ARTIST". Once it finds it, it stores the second field of the record into a variable. I don't know what the problem is for the... (7 Replies)
Discussion started by: klusps
7 Replies

6. Shell Programming and Scripting

Merging a lot of XML documents in one

Hi, I have a very basic knowledge of shell scripting & would like some help with a little problem I have. I have a lot of xml documents in a directory and I would like to merge them in one xml. The names of the documents are like: 111111___ΑΑ__Β-2005-2222___EN.xml... (0 Replies)
Discussion started by: corfuitl
0 Replies

7. Shell Programming and Scripting

XML::Simple Help!

I can loop through each roomtype but if a roomtype has more that one mealtype I get this error: Not a HASH reference The ForceArray option is enabled. Please Help! This is the dump from the XML that is begin returned to me: --------------------------------------------------------------- ... (2 Replies)
Discussion started by: novera
2 Replies

8. Shell Programming and Scripting

using XML::simple in shell scripting

CPAN provide xml::simple module which can be used to generate XML files. can i use this module in shell scripting? how? plzz give me an example to generate xml file using this module . you can also use some other module.. BUT SHELL SCRIPTING SHOULD ONLY BE USED (4 Replies)
Discussion started by: cynosure2009
4 Replies

9. HP-UX

XML parsing performace comparison with windows using sax

sorry wrong forum..i dont know how to delete this or how to move it to HP UX section... I tested SAX XML parsing using xerces(http://xerces.apache.org/xerces-j/). I tested on Windows XP and HP-UX . I found that parsing time on HP is 5 times that on Windows. My server startup reads a lot of XML... (1 Reply)
Discussion started by: saurabh.sid
1 Replies
Login or Register to Ask a Question