tje3d / domparser
1.0.0
2017-04-09 13:29 UTC
This package is not auto-updated.
Last update: 2024-09-20 18:54:12 UTC
README
这是一个简单的 DomParser,也可以解析无效的 HTML。它是 http://simplehtmldom.sourceforge.net/ 的编辑版本。
安装
composer require tje3d/domparser
示例
✔️ 解析字符串
$dom = Tje3d\DomParser\DomParser::parse(file_get_contents('url'))
✔️ 查询元素
$dom->find('.elementClass') // All element's with this class
$dom->find('#myId', 0) // First element with this id
$dom->find('[name=user]')
✔️ 可用函数
innerText, innerHTML, html, getAllAttributes, getAttribute, attr, hasAttribute, parentNode, nextSibling, previousSibling, nodeName