Link to home
Start Free TrialLog in
Avatar of jamie_lynn
jamie_lynn

asked on

What is the best HTML parser for PHP?

Hi,
What is the best html parser for PHP? Something like BeautifulSoup for Python.
Thanks
Jamie
Avatar of m_tawfick
m_tawfick

check this page for a good list:
http://www.info4php.com/?req=PHP_Editors
SOLUTION
Avatar of siliconbrit
siliconbrit

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jamie_lynn

ASKER

Well.. I want to parser that can search on tag name, attribute, or value.
....
<div id="rating">

</div>
....
i.e. divcontent = soup.findAll("div", { "id" : "rating" })
     Then search again from the results

Is there a html parser in PHP that does this?

Thanks
Jamie
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks hernst.  Can this handle messy html that everyone write on the web?  I was thinking about using dom parsers but I was reading that dom parsers does not do well with poor html.
i.e. No end tag, unquoted values, etc

Thanks
Jamie
If you have poor html, you could 1st use tidy to make it better html and then use it in dom. If the html is so poor that tidy fails, the user should fix it. No parser can do such things.
I'm glad I could help.  Thanks for the fun question, grade and points.

bol