Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 10th, 2006, 04:35 AM
John Raines
Guest
 
Posts: n/a
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 <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
Default 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


 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles