Hi Michael,

On 5/23/07, Michael Goopta <[EMAIL PROTECTED]> wrote:
How can I split the below string and get the multiple
web-addresses in a list: (i.e. the strings between <upsl-url>
and </upsl-url>

<upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url><upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url>
</ad-type>

Any time you can avoid using regular expressions to parse xml-ish
data, it's usually easier to do so.

#!/usr/bin/perl
use strict;
use warnings;

use XML::Simple;
use Data::Dumper;

my $xml;
{ local $/ = undef;
 $xml = <DATA>; }
# fixup unescaped ampersands
$xml =~ s/&/&amp;/g;

my $parsed = XMLin($xml, ForceArray => 1);

print Dumper($parsed);

__DATA__
<ad-type>
<upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url><upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url>
</ad-type>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to