in reply to AIM-Bot help again, please!

Welcome to the wonderful world of handling XML with perl.

Observation: Your basic problem is how to parse the XML data and get the desired value for a given tag.
Pointer:You can use Bundle::XML
Code:

use strict; use warnings; use LWP::Simple; use XML::Simple; my $zipcode = '03054'; my $site1 = get 'http://beta1.accuweather.com/beta1/dtwx_initialize.a +sp?zipcode='.$zipcode; my $DTWXSetup = XMLin($site1); my $Location = $DTWXSetup->{Location}; my $UFDB = $Location->{UFDB}; my $site2 = get 'http://beta1.accuweather.com/beta1/dtwx_curcon.asp?u +fdb='.$UFDB; my $CurrentConditions = XMLin($site2); my $Temperature = $CurrentConditions->{Temperature}; print "ZIP:$zipcode\nTemperature:$Temperature\n"; XMLout();
Few Liner:
use LWP::Simple; use XML::Simple; my $zipcode = shift; print XMLin(get 'http://beta1.accuweather.com/beta1/dtwx_curcon.asp?uf +db='. XMLin(get 'http://beta1.accuweather.com/beta1/dtwx_initiali +ze.asp?zipcode='.$zipcode)->{Location}->{UFDB})->{Temperature};
Point: I wish that you will make a point to learn more XML, from sites like XML Perl.

artist

Replies are listed 'Best First'.
Re: Re: AIM-Bot help again, please!
by Sleepaholic88 (Novice) on Mar 22, 2003 at 05:35 UTC
    It says that $zipcode requires explicit package name. Not exactly sure what that means.... And I would learn some XML, but homework, mostly, keeps me from that =(

      That error means that you are using strict (which is good) and you didn't declare $zipcode with my. If $zipcode is a global variable then put my $zipcode; at the top of your program somewhere. If its in a sub then put my $zipcode; in the sub somewhere before you use it or when you assign it (my $zipcode = ....)

      Hope that helps
      Chris

      Lobster Aliens Are attacking the world!
Re: Re: AIM-Bot help again, please!
by Sleepaholic88 (Novice) on Mar 24, 2003 at 18:13 UTC
    Thank you very much!!!! I used the first code, and it worked perfectly! The bot now returns values for:
    Current Condition
    Temperature
    ReelFeel
    Humidity
    UV Index
    Wind Direction and Speed
    Percipitation Thank you very much!