tried using XML::LibXML as well but I can't get it to return a valid data structure
You can use XML::LibXML but because of the xmlns="http://xmlns.sony.net..." in the TMSMessage tag you have to perform some namespace trickery. By referring to this node I came up with this snippet which may be of help:
my $text = q|<?xml version="1.0" encoding="UTF-8"?> <TMSMessage xmlns="http://xmlns.sony.net/d-cinema/tms-api/v1"> <MessageHeader> <Id>-1</Id> <Type>ListPerformances</Type> ...etc </TMSMessage>|; my $doc = XML::LibXML->load_xml(string => $text); my $xc = XML::LibXML::XPathContext->new( $doc->documentElement() ); $xc->registerNs( pfx => 'http://xmlns.sony.net/d-cinema/tms-api/v1' ); my @events = $xc->findnodes('//pfx:EventInfo'); for my $event (@events) { my $id = $xc->findvalue('pfx:EventId', $event); print "EventId: $id\n"; my @packs = $xc->findnodes('pfx:PreshowPackList/pfx:PreshowPack', +$event); if ( not @packs ) { print "No Packs\n"; next; } for my $pack (@packs) { my $pack_id = $xc->findvalue('pfx:PackId', $pack) || "No PackI +d"; print "PackId: $pack_id\n"; } }
Output using your sample XML:
EventId: 2015060400000157 No Packs EventId: 2015060400000164 No Packs EventId: 2015060200000562 PackId: b863a576-d8a3-4f5d-92a7-b66f876f6d7c PackId: No PackId PackId: a55164d0-faa7-4c7c-a688-ed36011add95 EventId: 2015060200000563 PackId: 760eb073-81f8-45cb-8553-484c5cecb740 PackId: No PackId PackId: a55164d0-faa7-4c7c-a688-ed36011add95

In reply to Re: XML Parsing Problems by tangent
in thread XML Parsing Problems by taralon

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.