gpt4 book ai didi

php - 在 PHP 中解析无效 HTML 的最佳方法

转载 作者:IT王子 更新时间:2023-10-29 00:05:59 26 4
gpt4 key购买 nike

有没有更好的方法来解析无效的 HTML 然后对其应用 Tidy?

旁注:在某些情况下,您无法使用 Tidy。Regexp 也不推荐我理解解析 html。

最佳答案

我会尝试这样的事情:http://php.net/manual/en/domdocument.loadhtml.php

从那个页面:

The function parses the HTML contained in the string source. Unlike loading XML, HTML does not have to be well-formed to load. This function may also be called statically to load and create a DOMDocument object.

关于php - 在 PHP 中解析无效 HTML 的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3606792/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com