0

Possible Duplicate:
Best methods to parse HTML
How to get href from anchor tag with particular class

hi guys,

I need an html parser. Baiscally given an html in a string i need to extract every href of

Which html parser for php do u suggest me? Someone that handles wrong html too.

Thanks

Community
  • 1
  • 1
  • 1
    Please search for existing questions/answers before you post a new question - this topic has already been covered in some detail. – John Parker Jan 19 '11 at 11:20

2 Answers2

0

I would recommend using DOMDocument, it's often (always?) compiled with PHP 5.

You can use DOMXpath for extracting all href attributes.

alexn
  • 57,867
  • 14
  • 111
  • 145
0

This is the best tool I have tested to parse HTML and extract data.

maid450
  • 7,478
  • 3
  • 37
  • 32
  • how many others did you test? ;) Suggested third party alternatives to [SimpleHtmlDom](http://simplehtmldom.sourceforge.net/) that actually use [DOM](http://php.net/manual/en/book.dom.php) instead of String Parsing: [phpQuery](http://code.google.com/p/phpquery/), [Zend_Dom](http://framework.zend.com/manual/en/zend.dom.html), [QueryPath](http://querypath.org/) and [FluentDom](http://www.fluentdom.org). – Gordon Jan 19 '11 at 11:23