Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > parsing HTML results

Reply
Thread Tools

parsing HTML results

 
 
John Raines
Guest
Posts: n/a
 
      12-10-2006
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


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      12-10-2006
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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ajax call to fetch multiple results from multiple queries and showing them 1 by 1 as the results comes. Biranchi Narayan Panda ASP .Net 0 02-21-2010 03:46 PM
How can I make this more efficient? (combining DataSet results with the results of a DB lookup.) Ken Fine ASP .Net 3 07-23-2008 08:11 AM
Prefix increment/decrement results in lvalue, but postfix one results in rvalue? lovecreatesbeauty C++ 8 09-12-2005 10:23 PM
Displaying results as "pages" of a JTable and sorting across all results ... Monique Y. Mudama Java 1 06-28-2005 01:01 AM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM



Advertisments