in reply to Problem with Regex
A solution using a pure-Perl XML parser:
use strict; use warnings; use Mojo::DOM; my $dom = Mojo::DOM->new()->parse(do { local $/; <DATA> }); # here you can use any other tag than 'title' too: print $dom->at('title')->text; __DATA__ <page> <title>Some Title</title> <id>1149707</id> <revision> <id>4220</id> <timestamp>2011-04-02T16:47:40Z</timestamp> <contributor> <username>some User Name</username> <id>268</id> </contributor> <minor /> <text xml:space="preserve">some Text ... ......... ..................... ..................... .....................</text> </revision> </page> <page> <title>Some other Title</title> <id>11497077</id> <revision> <id>42290</id> <timestamp>2011-05-02T16:47:40Z</timestamp> <contributor> <username>some Other User Name</username> <id>2688</id> </contributor> <minor /> <text xml:space="preserve">some Other Text ... ......... ......... ..................... ..................... .....................</text> </revision> </page>
See Mojo::DOM for other extraction methods it offers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem with Regex
by ŞuRvīvőr (Novice) on Aug 01, 2011 at 13:09 UTC | |
by ŞuRvīvőr (Novice) on Aug 01, 2011 at 13:11 UTC | |
by moritz (Cardinal) on Aug 01, 2011 at 13:32 UTC |