Hi Monks!
This code is the best I found to represent what I am trying to do. I am trying to save the results of this code into a XML file so I can use in another script, I tried using "Data::Dumper" but the structure saved is complicated to use, it saves the file in 15 chunks of data like:
$VAR1 = { 'xml_api_reply' => { '-version' => '1', 'weather' => { .... } $VAR1 = { 'xml_api_reply' => { '-version' => '1', 'weather' => { .... } ....

One block of data for each zip code (15).
Is there any better way to save this result in a file as one big XML?
Here is the code I am using to try this example:
#!/usr/bin/perl -w use strict; use CGI qw(-oldstyle_urls :standard); use XML::TreePP; use XML::XPath; use XML::Simple; use Data::Dumper; use Date::Format; use Date::Parse; my $q = new CGI; $| = 1; my @zipcode = qw(02151 01908 02638 02669 02670 02536 02642 02574 02332 + 02601 02045 01930 02152 27943 02169); my ($currtempf, $currtempc, $currhumidity, $currcondition, $currwind, +$todayhigh, $todaylow, $todaycond, $tomorrowcond); my ($city, $url, $tpp, $tree); #set $Data::Dumper::Purity to 1 if you have nested references $Data::Dumper::Purity = 1; open (FILE, "> data.txt") or die "can't open $tree: $!"; foreach my $zip(@zipcode) { next unless $zip =~ /^(\d{5})$/; $url = "http://www.google.com/ig/api?weather=".$zip ; $tpp = XML::TreePP->new(); $tree = $tpp->parsehttp( GET => $url ); print FILE Dumper($tree); } close FILE or die "can't close $tree: $!";

Thanks for the help!!!

In reply to Save results into one big XML file help! by Anonymous Monk

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.