Hello, merry xmas (in a politically incorrect way to all you other religion types)

Im trying still !!! to get an XML document parsed. I have used XML::Parser, and left it as default SAX as i dont want ot edit the document, only read it. My code is very simple, but i get some random results i was not expecting.

#!/usr/bin/perl -w use strict; use warnings; use XML::Parser; my $xml; my $results; $xml = new XML::Parser(Style => 'Debug'); $xml->parsefile('info.xml'); $xml->parse('<attribute Name="Column_Type" >F635 Median</attribute>');

this gives the following output:

\\ () entries || #10; entries || #9;#9; entries \\ (ID 10 Name Array_1_Measurement Column Metadata) entries enumeration || #10; entries enumeration || #9;#9;#9; entries enumeration \\ (Name Column_Type) entries enumeration attribute || F635 Median entries enumeration // entries enumeration || #10; entries enumeration || #9;#9;#9; entries enumeration \\ (Name Data_Type) entries enumeration attribute || INTEGER entries enumeration // entries enumeration || #10; entries enumeration || #9;#9;#9; entries enumeration \\ (Name Origin) entries enumeration attribute || Feature entries enumeration // entries enumeration || #10; entries enumeration || #9;#9;#9; entries enumeration \\ (Name Quantitation_Type) entries enumeration attribute || MeasuredSignal entries enumeration // entries enumeration || #10; entries enumeration || #9;#9;#9; entries enumeration \\ (Name Scale) entries enumeration attribute || LINEAR entries enumeration // entries enumeration || #10; entries enumeration || #9;#9;#9; entries enumeration \\ (Name LabelledExtract) entries enumeration attribute || - entries enumeration // entries //

I was just expecting to get back either F635 Median or all the info relating to that node.

The xml doc contains:

<?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>

Can any body tell me if this is whats supposed to happen or am i not defining the nodes in the perl script properly.

Any help would be great.
MonkPaul.


In reply to 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.