Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - parsing HTML results

 
Thread Tools Search this Thread
Old 12-10-2006, 04:59 AM   #1
Default parsing HTML results


Hello-

I am trying to parse HTML results which look like this:

<html>
<body>
<span class=aaa>this is a test</span><span class=bbb>testing
again</span><span class=aaa>test number 3</span>
</body>
</html>

All the <span> are on one line.

In this particular case, I want to match all the <span class=aaa> so that my
results would look like:

this is a test
test number 3

I was fairly successful with a regex like /<span class=aaa>(.*)</span>/ but
I could only get the first result.

Is there an easy way to match <span class=aaa>*</span> and return the
contents within the tag? And to either insert the results into an array, or
have the ability to loop through the results?

Thanks




John Raines
  Reply With Quote
Old 12-10-2006, 11:13 AM   #2
Jürgen Exner
 
Posts: n/a
Default Re: parsing HTML results

John Raines wrote:
> I am trying to parse HTML results which look like this:

[...]
This has been discussed a gazillion of times.

> Is there an easy way to match <span class=aaa>*</span> and return the
> contents within the tag? And to either insert the results into an
> array, or have the ability to loop through the results?


Absolutely. The best way to do it is as described in the FAQ: just use a
parser to parse HTML.

jue


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump