Problems? Is your data what you think it is? | |
PerlMonks |
Re: Removing duplicate subtrees from XMLby dingus (Friar) |
on Dec 03, 2002 at 08:28 UTC ( [id://217155]=note: print w/replies, xml ) | Need Help?? |
Two suggestions: 1) if the data is machine generated and you know that it will be identical when the gene sequence etc. is identical, that is to say you know that you will never see the tags presented in a a different order then you can usefully compare whole records at a time by setting the input record seperator appropriately: Note that in addition to the drawback noted above, this code requires records that are identical to be adjacent. 2) A better way is probably to XML::Twig (or XML::Simple perhaps) the file and compare the resulting data structures. This avoids the tags must be in identical order problem and, depending on your code, may also avoid the identical records must be adjacent problem too. A cunning way to compare two arbitrary data structures is to use Data::Dumper and string comparisons: The disadvantage is that this second method will be quite a lot slower. Because I quite like processing enormous files quickly I have used methods similar to the first method successfully on records pulled from pubmed. Dingus Enter any 47-digit prime number to continue.
In Section
Seekers of Perl Wisdom
|
|