Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help wanted for comparing two xml files

Status
Not open for further replies.

dipti1

Programmer
Jul 25, 2006
9
US
Hi,

I need to compare two xml files. I need to compare only the tags and not the values. If it was only to compare two files, I could use File::compare.

However, for my purpose of comparing only the tags, I somehow will have to extract the words between the < and > and compare each of them with their counterparts ( in the other xml file).

The problem is that the strings in the xml files do not necessarily have spaces in between tags or words. I am having difficulty solving this problem of comparing two xml files. Part of xml file looks like:

<name>Priya</name>
<address> California </address>

I should not compare the values like Priya or California. I just have to compare the structure of the two xml files.

If any one could help me or give some idea, that would be great.

Thanks a lot in advance,
Priyanka

 
If you treating these as more than just files, but as xml files, then you should use modules that treat them as xml files.


The above is the simplest module that you could use, but you'll have to create the data comparison routines yourself.

If you were testing for isomorphism, then you could use some of other cpan module for the data comparison as well:


However, given that you've applied special requirements, you'll most likely have to do the comparison yourself.

- Miller
 
There's also an XML::Diff on CPAN, although I've not tried it...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top