in reply to extracting href data in XML

Here is a example. Remember that perl is casesensitive. use strict; use warnings;
use strict; use warnings; use XML::Twig; my $tw = XML::Twig->new( TwigHandlers => { 'NBA/HomeTeam' => \&nba } ) +; $tw->parse(<<__XML__); <NBA> <HomeTeam href="Celtics"/> <VisitorTeam href="Bulls"/> <Stadium id="FleetCenter">blabla</Stadium> </NBA> __XML__ $tw->flush; sub nba { my ( $twig, $nba ) = @_; $nba->set_att( href => 'MyHomeTeam' ); $twig->flush; }
Boris

Replies are listed 'Best First'.
Re^2: extracting href data in XML
by kanz0r (Initiate) on Aug 07, 2005 at 09:39 UTC
    thank you very much!
Re^2: extracting href data in XML
by kanz0r (Initiate) on Aug 08, 2005 at 08:52 UTC
    still can't figure one thing out, why i can't use the following code just to get the data "Celtics"
    $hometeam -> ('att') -> ('href');

      Because att is a method, that you call with the syntax $hometeam ->att('href');?

        k got it :)