在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:blowsie/Pure-JavaScript-HTML5-Parser开源软件地址:https://github.com/blowsie/Pure-JavaScript-HTML5-Parser开源编程语言:JavaScript 78.4%开源软件介绍:Pure JavaScript HTML5 ParserA working demo can be seen here. Credit goes to John Resig for his code written back in 2008 and Erik Arvidsson for his code written prior to that. This code has been updated to work with HTML 5 to fix several problems. 4 Libraries in One!A SAX-style APIHandles tag, text, and comments with callbacks. For example, let’s say you wanted to implement a simple HTML to XML serialization scheme – you could do so using the following:
XML SerializerNow, there’s no need to worry about implementing the above, since it’s included directly in the library, as well. Just feed in HTML and it spits back an XML string.
DOM BuilderIf you’re using the HTML parser to inject into an existing DOM document (or within an existing DOM element) then htmlparser.js provides a simple method for handling that:
DOM Document CreatorThis is a more-advanced version of the DOM builder – it includes logic for handling the overall structure of a web page, returning a new DOM document. A couple points are enforced by this method:
You would use the method like so:
While this library doesn’t cover the full gamut of possible weirdness that HTML provides, it does handle a lot of the most obvious stuff. All of the following are accounted for: Unclosed Tags:
Empty Elements:
Block vs. Inline Elements:
Self-closing Elements:
Attributes Without Values:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论