XML, the Perl Way

Home XML::Twig Modules Talks Articles Tutorials Reports Tools PGC mirod Le Blog

28 Feb 2006

XML::Twig Examples: Getting the US Dollar / Euro conversion rate

Based on an example from Growing Twigs, here is a convenient one-liner that shows how you can use XML::Twig to do some quick'n dirty screen-scraping.

The nparse method appeared in XML::Twig 3.23, it combines a new and an xparse, an other new method that parses what thrown at it, be it a file, filehandle or string, XML or HTML. It is very convenient for one-liners and tests.

perl -MXML::Twig -l -e'print XML::Twig
       ->nparse( "http://www.x-rates.com/index.html")
       ->first_elt( q{a[@href="/d/USD/EUR/graph120.html"]})->text'

[XML::Twig Examples] [permalink]



Comments

Recent

Archives

2006