Im fairly new to Perl and would need some help on the following task.
So here is a scenario of what im trying to do. I have 3+ different XML files and need to achieve the following
I'm looking for common elements contents that share information that belongs to the same person. Example:

#-----My First XML File-----# <ClubMembers> <Member id=1> <Name>Jack</Name> <Sport>Soccer Swimming Hockey</sport> <Age>18</Age> <Level>beginner</Level> <Gender>M</Gender> </Player> <Member id=2> <Name>Tom</Name> <Sport>Soccer</sport> <Age>20</Age> <Level>advanced</Level> <Gender>M</Gender> </Member> <Member id=3> <Name>Sally</Name> <Sport>Swimming Hockey</sport> <Age>19/Age> <Level>beginner</Level> <Gender>F</Gender> </Member> </ClubMembers> #-----My second XML File-----# <SoccerMembers> . . . . . . <Player Id=7> <Info> <MemberName>Jack</MemberName> <Position>defense</Position> <Level>advanced</Level> </Info> </Player> . . . . <Player Id=15> </Info> <MemberName>Jack</MemberName> <Position>goalkeeper</Position> <Level>advanced</Level> </Info> </Player> </SoccerMembers> #-----My third and Fourth XML files should be same as my second XML fi +le-----#

As you could see from the above example "Jack" can be in many files and more than once within the same file. What I'm trying to approach is basically:
1) from my first XML file get the element Name "<Name>" for the first member
2) get the "text content" of the element <Name>
3) loop through my second XML file compare my text content "<Name>Jack</Name>" with the element "<MemberName>Jack</MemberName>" text content,
If both are equal value. Then, get all element <Player Id> contents and copy it to my new file. Then move to the next Player compare names so on and so forth.
The same applies for the rest of the files
4) assuming the elements share the same name across all files except the first file which im using as my primary value.
output example im trying to achieve:
<Club Location="A"> <Member Name="member name I got from my <Name> element i.e Jack"> <Name>Jack</Name> <Sport>Soccer Swimming Hockey</sport> <Age>18</Age> <Level>beginner</Level> <Gender>M</Gender> <FILE2> <Info> <MemberName>Jack</MemberName> <Position>defense</Position> <Level>advanced</Level> </Info> <Info2> <MemberName>Jack</MemberName> <Position>goalkeeper</Position> <Level>advanced</Level> </Info2> </FILE2> <File3> <Info> <MemberName>Jack</MemberName> <Position>defense</Position> <Level>advanced</Level> </Info> <Info2> <MemberName>Jack</MemberName> <Position>goalkeeper</Position> <Level>advanced</Level> </Info2> </File3> </Member Name> <Member Name="Next Member from File1"> . . . . </Member Name>
Please excuse the example but this is the easiest way I can explain what im trying to achieve. I hope someone could provide me with the easy to understand approach especially that I need to check more than one file at the same time.


In reply to find all common XML element text contents by zak_s

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.