php lib for parsing html to DOM hierarchy tree

2019-07-29 00:05发布

I need some php library to parse html content to DOM tree Like this:

html
 |--head
 |    |---title--title_content
 |    |---meta--meta_content
 |--body
 |    |---div
 |    |    |--div--div_content

.. etc

and also repare or clean the invalid html.

ITS not only for HTML BUT event for any XML style mark-up language. basically a parent-child style.

标签: php html parsing
3条回答
神经病院院长
2楼-- · 2019-07-29 00:30

Simple HTML DOM works great with HTML, even invalid HTML, but I am not sure how it handles XML. If you are looking for XML manipulation, the php documentation has a list of libraries.

查看更多
做个烂人
3楼-- · 2019-07-29 00:32

I've just come across QueryPath in delicious, seems quite nice.

查看更多
Fickle 薄情
4楼-- · 2019-07-29 00:41

Is there any problem with PHP's built in Document Object Model extension? Sometimes a bit clunky, yes, but it's built right in and evaluates rather quickly in my experience, whereas Simple HTML DOM is (again, in my experience) prone to lots of snags and slowdowns.

查看更多
登录 后发表回答