Connecting Tech Pros Worldwide Help | Site Map

parsing HTML results

  #1  
Old December 10th, 2006, 04:35 AM
John Raines
Guest
 
Posts: n/a
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 <spanare on one line.

In this particular case, I want to match all the <span class=aaaso 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>*</spanand 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


  #2  
Old December 10th, 2006, 10:55 AM
Jürgen Exner
Guest
 
Posts: n/a

re: parsing HTML results


John Raines wrote:
Quote:
I am trying to parse HTML results which look like this:
[...]
This has been discussed a gazillion of times.
Quote:
Is there an easy way to match <span class=aaa>*</spanand 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


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing HTML, extracting text and changing attributes. sebzzz@gmail.com answers 9 June 18th, 2007 08:05 PM
Parsing HTML/XML documents pabloski@giochinternet.com answers 2 April 26th, 2007 09:05 PM
Parsing HTML mtuller answers 3 February 14th, 2007 01:25 PM
using MSHTML for parsing HTML files in c# philipl@vistatec.ie answers 9 November 15th, 2005 12:30 PM