HTML 解析器验证标签
我需要 html 解析,它能够识别生成的 html 中的错误,如果标签未关闭,则关闭它并返回有效的 html。
更多详细信息:我正在从数据库获取数据并打破该记录以在我的网站上显示部分详细信息,然后单击更多按钮然后显示完整内容。断开字符串后然后验证。
我已经使用过 Html Agility Pack,但我是新使用它,如果这个库解决了我的问题,请指导我如何使用(教程)或建议我另一个库。
I need html parse which have capability to identify error in generated html and if tags are not closed then close it and return the valid html.
More detail: i am getting data from database and break that record to show partial detail on my website to click on more button then show complete content. After breaking string then validate.
I have already used Html Agility Pack but i am new to use it, if this library solve my issue then guide me how (tutorial) or suggest me another library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这样的图书馆并不存在。问题是,有些库确实可以识别 HTML 中的错误,但无法为您修复它们。
我认为使用 W3C 验证器 作为服务是最好的起点。有一个开源库,它使用 W3C 验证器的 API 来验证文档,并为您提供有效或无效的响应以及错误和警告。我将从这里开始,然后从那里继续。
I don't think such a library does exist. The problem is, that some libraries can indeed identify errors in your HTML but they cant fix them for you.
I think using the W3C validator as a service is the best starting point here. There's an open source library which uses the API of the W3C validator to validate a document and gives you the response if it is valid or not as well as errors and warnings. I would start with this and then go on from there.
以下是万维网联盟 (W3C) 提供的几个验证程序:
Windows:http:// validator.w3.org/docs/install_win.html
UNIX / Linux:http:// validator.w3.org/docs/install.html
您还可以使用他们的网络服务来验证您的 CSS、HTML、XML, XHTML, JavaScript 和许多其他网络技术。 W3C 是保持互联网高度互操作性和互联网设备相互兼容的监督者之一。
Here are a couple of validation programs from the World Wide Web Consortium, the W3C:
Windows: http://validator.w3.org/docs/install_win.html
UNIX / Linux: http://validator.w3.org/docs/install.html
You can also use their web services to validate your CSS, HTML, XML, XHTML, JavaScript and many other web technologies. The W3C is one of the overseers of keeping the Internet highly interoperable and internet devices somewhat compatible with each other.