How to compare strings in xml file using perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rucha Sharma

    #1

    How to compare strings in xml file using perl

    This is content of one file A.xml
    ...
    ...
    <EXTRAINFO OldID='3C3A6937 4E11C25C8F74A05 444FD227F'>
    </EXTRAINFO>
    </OBJECT>
    <OBJECT OBJECTTYPE='Phy sical Folder' UUID='FOLDER-physical-NEW1' PRIORITY='100'
    ...
    ...

    This is content of second file B.xml
    ...
    ...
    <EXTRAINFO OldID='37D45C40 53907E4D3183C48 E2B2E36E'>
    </EXTRAINFO>
    </OBJECT>
    <OBJECT OBJECTTYPE='Phy sical Folder' UUID='FOLDER-physical-NEW1' PRIORITY='100' >
    ...
    ...

    I just need to check if <OBJECT OBJECTTYPE='Phy sical Folder' UUID='FOLDER-physical-NEW1' PRIORITY='100' > is present in both .
    How do I do this in perl ?
  • gunmetal
    New Member
    • Dec 2010
    • 3

    #2
    Rucha:

    Here's the algorithm:

    Open file A.xml
    Parse each line to match "<OBJECT OBJECTTYPE=..."
    If match is found, flag or store in variable, say $a
    Close file A.xml

    Open file B.xml
    Parse each line to match "<OBJECT OBJECTTYPE=..."
    If match is found, flag or store in variable, say $b
    Close file B.xml

    Test if ($a eq $b) { print "Match\n"; }

    Comment

    Working...