Hi Guys, I figured it out.. I had been working on this for over a while but I figured my solution out..

nevertheless, I'll show you what I did, I did put in some modifications so that my data is displayed as needed by me

The file I pasted was a sample file, my actual file looks like this..

<response> <version>0.1</version> <termsofService>http://www.wunderground.com/weather/api/d/terms.ht +ml</termsofService> <features> <feature>history</feature> </features> <history> <date> <pretty>October 4, 2010</pretty> <year>2010</year> <mon>10</mon> <mday>04</mday> <hour>12</hour> <min>00</min> <tzname>America/New_York</tzname> </date> <utcdate> <pretty>October 4, 2010</pretty> <year>2010</year> <mon>10</mon> <mday>04</mday> <hour>16</hour> <min>00</min> <tzname>UTC</tzname> </utcdate> <observations> <observation> <date> <pretty>12:54 AM EDT on October 04, 2010</pret +ty> <year>2010</year> <mon>10</mon> <mday>04</mday> <hour>00</hour> <min>54</min> <tzname>America/New_York</tzname> </date> <utcdate> <pretty>4:54 AM GMT on October 04, 2010</prett +y> <year>2010</year> <mon>10</mon> <mday>04</mday> <hour>04</hour> <min>54</min> <tzname>UTC</tzname> </utcdate> <tempm>13.9</tempm> <tempi>57.0</tempi> <dewptm>7.8</dewptm> <dewpti>46.0</dewpti> <hum>67</hum> <wspdm>35.2</wspdm> <wspdi>21.9</wspdi> <wgustm>48.2</wgustm> <wgusti>29.9</wgusti> <wdird>40</wdird> <wdire>NE</wdire> <vism>16.1</vism> <visi>10.0</visi> <pressurem>1022.5</pressurem> <pressurei>30.20</pressurei> <windchillm>-999</windchillm> <windchilli>-999</windchilli> <heatindexm>-9999</heatindexm> <heatindexi>-9999</heatindexi> <precipm>-9999.00</precipm> <precipi>-9999.00</precipi> <conds>Overcast</conds> <icon>cloudy</icon> <fog>0</fog> <rain>0</rain> <snow>0</snow> <hail>0</hail> <thunder>0</thunder> <tornado>0</tornado> <metar>METAR KBOS 040454Z 04019G26KT 10SM SCT031 B +KN110 OVC140 14/08 A3020 RMK AO2 PK WND 05027/0439 SLP225 T01390078 4 +01500083</metar> </observation> <observation> <date> <pretty>1:54 AM EDT on October 04, 2010</prett +y> <year>2010</year> <mon>10</mon> <mday>04</mday> <hour>01</hour> <min>54</min> <tzname>America/New_York</tzname> </date> <utcdate> <pretty>5:54 AM GMT on October 04, 2010</prett +y> <year>2010</year> <mon>10</mon> <mday>04</mday> <hour>05</hour> <min>54</min> <tzname>UTC</tzname> </utcdate> <tempm>12.8</tempm> <tempi>55.0</tempi> <dewptm>8.3</dewptm> <dewpti>46.9</dewpti> <hum>74</hum> <wspdm>29.6</wspdm> <wspdi>18.4</wspdi> <wgustm>42.6</wgustm> <wgusti>26.5</wgusti> <wdird>50</wdird> <wdire>NE</wdire> <vism>16.1</vism> <visi>10.0</visi> <pressurem>1023.0</pressurem> <pressurei>30.21</pressurei> <windchillm>-999</windchillm> <windchilli>-999</windchilli> <heatindexm>-9999</heatindexm> <heatindexi>-9999</heatindexi> <precipm>0.0</precipm> <precipi>0.00</precipi> <conds>Light Rain</conds> <icon>rain</icon> <fog>0</fog> <rain>1</rain> <snow>0</snow> <hail>0</hail> <thunder>0</thunder> <tornado>0</tornado> <metar>METAR KBOS 040554Z 05016G23KT 10SM -RA FEW0 +18 OVC095 13/08 A3021 RMK AO2 PK WND 04027/0458 RAB18 SLP230 P0000 60 +000 T01280083 10139 20128 55000</metar> </observation> </observations> </history> </response>

here is what i am trying to do..

#!usr/bin/perl #use strict; use warnings; use XML::TreeBuilder; #use XML::Parser; #use Data::Dumper; my $root= XML::TreeBuilder->new(); $root->parsefile('weateg.XML'); #print Dumper($root); my @observation=$root->look_down(_tag=>'date'); foreach my $h (@observation) { printf "%s: %d-%d-%d %d:%d\t", $h->attr('date'), $h->look_down(_tag => 'year')->as_text,$h->look_down(_tag => 'mon' +)->as_text,$h->look_down(_tag => 'mday')->as_text,$h->look_down(_tag +=> 'hour')->as_text,$h->look_down(_tag => 'min')->as_text; }

In reply to Re: Extracting from repetitive multi level tags containing repetitive tags using Perl by Gouri
in thread Extracting from repetitive multi level tags containing repetitive tags using Perl by Gouri

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.