Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: XML processing

by Tanktalus (Canon)
on Aug 06, 2005 at 02:44 UTC ( [id://481427]=note: print w/replies, xml ) Need Help??


in reply to XML processing

Seconding borisz's advice, here's some (untested) XML::Twig code to do this, in case you want to continue doing stuff with the results in perl:

use XML::Twig; # ... my $twig = XML::Twig->new(); $twig->parsefile($XmlFile); my @a_elements = $twig->get_xpath("//a"); foreach my $el (@a_elements) { my $text = $el->text(); # do stuff with $text. }
It's actually pretty easy, once you know which APIs you want ;-)

Update: Changed loop variable from $a to $el when reminded by graff. Tks.

Replies are listed 'Best First'.
Re^2: XML processing
by graff (Chancellor) on Aug 06, 2005 at 16:24 UTC
    But it would be better not to use "$a" as the name of the iterator variable in the "for" loop, in case "doing stuff" includes using "sort".
Re^2: XML processing
by shreya (Novice) on Aug 10, 2005 at 22:31 UTC

      something like $ElementA .= $element->sprint;?

      Thanks Mirod. This worked. I am still trying to get used to this response method. Didnt realise that someone replied ot my old posts. Wish there was a way to notify by email when someone replies to your posts. Later
        In your User Settings you can turn on "msg me when there's a reply to one of my posts".

        (update: Of course, this post might be pointless if you don't check old posts)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://481427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-25 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found