I thought that may be there is a way to convert it to xml tags, since I need to display a difference in readable format on screen.

Of course there is a way, but you don't specify HOW it should be converted

I'd like to know if there is another way to display difference between two xml files...

Not using XML::SemanticCompare :)

That is the format XML::SemanticCompare uses for comparison of likeness

Its practically xpath, and hey, it is human readable, even if WIDE and vague :) its not meant for producing patches

#!/usr/bin/perl -- use strict; use warnings; use XML::SemanticCompare; my $control = <<'__XML__'; <?xml version="1.0" encoding="UTF-8"?> <moby:MOBY xmlns:moby="http://www.biomoby.org/moby" xmlns:foobar="http +://www.biomoby.org/moby2"> <moby:mobyContent> <moby:mobyData moby:queryID="sip_1_"> <moby:Simple moby:articleName="allele"> <moby:Object moby:id="cho" moby:namespace="DragonDB_Allele"/> </moby:Simple> </moby:mobyData> </moby:mobyContent> </moby:MOBY> __XML__ my $test = <<'__XML__'; <?xml version="1.0" encoding="UTF-8"?> <moby:MOBY xmlns:moby="http://www.biomoby.org/moby" xmlns:foobar="http +://www.biomoby.org/moby2"> <moby:mobyContent> <moby:mobyData moby:queryID="sip_1_"> <moby:Simple moby:articleName="allele"> <moby:Object moby:id="cho" moby:namespace="DragonDB_Allele"/> </moby:Simple> <moby:Simple moby:articleName="allele2"> <moby:Object moby:id="CHI" moby:namespace="DragonDB_Allele">fo +o</moby:Object> </moby:Simple> </moby:mobyData> </moby:mobyContent> </moby:MOBY> __XML__ my $C = XML::SemanticCompare->new(); my $diffs_arrayref = $C->diff($control, $test) ; for ( my $ix = 0; $ix < $#$diffs_arrayref; $ix +=2 ){ my $a = $diffs_arrayref->[$ix]; my $b = $diffs_arrayref->[$ix+1]; print "Old: \n", fart($a),"\n", "New: \n", fart($b),"\n", "#" x 33, "\n"; } sub fart { local $_ = $_[0]; s{\'\]/}{']\n /}g; return $_; } __END__ Old: /MOBY[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyContent[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyData[namespace-uri() = 'http://www.biomoby.org/moby'] /Simple[namespace-uri() = 'http://www.biomoby.org/moby'] / New: /MOBY[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyContent[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyData[namespace-uri() = 'http://www.biomoby.org/moby'] /Simple[namespace-uri() = 'http://www.biomoby.org/moby'] /@[articleName='allele2' and namespace-uri() = 'http://www.biomoby +.org/moby'] ################################# Old: /MOBY[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyContent[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyData[namespace-uri() = 'http://www.biomoby.org/moby'] /Simple[namespace-uri() = 'http://www.biomoby.org/moby'] /Object[namespace-uri() = 'http://www.biomoby.org/moby'] / New: /MOBY[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyContent[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyData[namespace-uri() = 'http://www.biomoby.org/moby'] /Simple[namespace-uri() = 'http://www.biomoby.org/moby'] /Object[namespace-uri() = 'http://www.biomoby.org/moby'] /@[namespace='DragonDB_Allele' and namespace-uri() = 'http://www.b +iomoby.org/moby'] ################################# Old: /MOBY[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyContent[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyData[namespace-uri() = 'http://www.biomoby.org/moby'] /Simple[namespace-uri() = 'http://www.biomoby.org/moby'] /Object[namespace-uri() = 'http://www.biomoby.org/moby'] /@[id='CHI' and namespace-uri() = 'http://www.biomoby.org/moby'] New: /MOBY[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyContent[namespace-uri() = 'http://www.biomoby.org/moby'] /mobyData[namespace-uri() = 'http://www.biomoby.org/moby'] /Simple[namespace-uri() = 'http://www.biomoby.org/moby'] /Object[namespace-uri() = 'http://www.biomoby.org/moby'] /text()=foo #################################

Take a close look at the source, its really not that complicated

Esp see XML::SemanticCompare::SAX sub start_element


In reply to Re^3: diff output of XML::SemanticCompare by Anonymous Monk
in thread diff output of XML::SemanticCompare by gdanenb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.