in reply to Parsing a highly nested XML file correctly and efficiently

I played with your XML in XML::XSH2. It has a shell/REPL, so it's easy to discover the correct XPath expressions there by trial and error. It's a wrapper around XML::LibXML where you can use the same XPath expressions if speed is your concern.
open file.xml ; for /DatatoParse/elt/Nest1/elt/Nest2/elt { my $top = ancestor::elt[last()] ; echo :s $top/d1 , $top/d2 , (d5/X) , (d5/Y) , (d6/X) , (d6/Y) , (N +est3/Nest4/d7/d9/d10/d11) ; }

Output:

TV show 1,Heroes,-2,-3,5,8,yipppeee TV show 1,Heroes,-2,-3,5,8,yipppeee TV show 1,Heroes,-2,-3,5,8,yipppeee TV show 1,Heroes,-2,-3,5,8,yipppeee TV show 2,Prison Break,-2,-3,5,8,yipppeee TV show 2,Prison Break,-2,-3,5,8,yipppeee TV show 2,Prison Break,-2,-3,5,8,yipppeee TV show 2,Prison Break,-2,-3,5,8,yipppeee TV show 4,Alias,-2,-3,5,8,yipppeee TV show 4,Alias,-2,-3,5,8,yipppeee TV show 4,Alias,-2,-3,5,8,yipppeee TV show 4,Alias,-2,-3,5,8,yipppeee

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Parsing a highly nested XML file correctly and efficiently
by Ppeoc (Beadle) on Jun 09, 2016 at 18:38 UTC
    Thanks Choroba! I haven't used XSH2 or LibXML before. This is completely new to me. But its looks like you have given me a good starting point. I will need to read up on this before I understand wat you have done. Really appreciate the help!