in reply to file handling error
When I tried using XML::Parser on it, I got failures on the entity references λ and — -- maybe a good DTD will solve this. (I just converted them to unicode numeric entities -- λ — respectively.)
But beyond that, your 15 lines of XML data is badly messed up in terms of tag layout, and cannot be parsed as XML. Here's a little one-liner that will reduce your data sample to just the tags, putting one tag per line:
That just replaces 0 or more characters between a > and a following < with a line-feed. Look carefully at the output, and you'll see what a mess it is. One big issue is that it starts with <sec>, and there's additional XML content after the corresponding </sec> token.perl -pe 's{(?<=>)[^<]*}{\n}g' your_file.xml
UPDATE: To see what I'm talking about more clearly, pipe the output of that one-liner through grep, like this:
perl -pe 's{(?<=>)[^<]*}{\n}g' your_file.xml | grep sec
|
|---|