You should read the documentation for XML::Parse which tells you that that is what you will get.

To solve your actual problem try using XML::TreeBuilder. Here's some code to get you started:

use strict; use warnings; use XML::TreeBuilder; my $xml; my $results; $xml = XML::TreeBuilder->new; $xml->parse(do{local $/; <DATA>}); my @elements = $xml->look_down('Name', 'Column_Type'); for (@elements) { next if $_->as_text () ne 'F635 Median'; print $_->parent ()->as_text(); } __DATA__ <?xml version="1.0" encoding="UTF-8"?> <entries> <enumeration ID="10" Name="Array_1_Measurement Column Metadata +" > <attribute Name="Column_Type" >F635 Median</attribute> <attribute Name="Data_Type" >INTEGER</attribute> <attribute Name="Origin" >Feature</attribute> <attribute Name="Quantitation_Type" >MeasuredSignal</attri +bute> <attribute Name="Scale" >LINEAR</attribute> <attribute Name="LabelledExtract" >-</attribute></enumerat +ion> <enumeration ID="1" Name="Array_1_Measurement Data" > <attribute Name="Gene" >AAC1</attribute> <attribute Name="F635 Median" >325</attribute> <attribute Name="B635 Median" >103</attribute></enumeratio +n> <enumeration ID="2" Name="Array_1_Measurement Data" > <attribute Name="Gene" >AAC3</attribute> <attribute Name="F635 Median" >389</attribute> <attribute Name="B635 Median" >115</attribute></enumeratio +n> </entries>

Prints:

F635 Median INTEGER Feature MeasuredSignal LINEAR -

DWIM is Perl's answer to Gödel

In reply to Re: XML Parsing by GrandFather
in thread XML Parsing by MonkPaul

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.