Perhaps many people will think that the current HTML parser is enough, and even simple regular expressions can already meet the needs of manipulating HTML documents. Yes, for the vast majority of HTML documents on the Internet, in fact, most of them meet the XHTML specifications, and their parsing does not require a powerful parser. But a powerful parser is one thing, and a perfect parser is another.
Jumony Core first provides a nearly perfect HTML parsing engine, and its parsing results are infinitely close to those of the browser. Whether it is elements without end tags, elements with optional end tags, tag attributes, or CSS selectors and styles, all legal and illegal HTML documents will be parsed by the browser, and Jumony will parse them into whatever they are. Sample. In other words, the results of Jumony parsing are the same as the results of browser parsing, so you no longer have to worry about whether the HTML document can be recognized. If the browser can read it, Jumony can understand it.
There is only one step between perfection and power, but a perfect parser allows you to never have to care about the HTML source document.
The following is an incomplete list of features supported by the Jumony parser
特性 | 例子 |
孤立的<解析为文本 | < a应当解析为< a |
孤立的>解析为文本 | >应当解析为> |
标记属性(没有值的属性) | |
元素丢失结束标签 | |
可选结束标签元素 "body", "colgroup", "dd", "dt", "head", "html", "li", "option", "p", "tbody", "td", "tfoot", "th", "thead", "tr" |
abc 123 |
无结束标签元素 "area", "base", "basefont", "br", "col", "frame", "hr", "img", "input", "isindex", "link", "meta" , "param", "wbr", "bgsound", "spacer", "keygen" |
|
CDataElement | ##<script>if ( 1<a ) alert( "< p>" );</script> |
"script", "style", "textarea", "title" | |
Preformatted elements | <span style="font-family:courier new,courier;font-size:12px;">There is a space in front<span class="font5"></span> |
Use single quotes for attribute values | ##< a href='#'>|
HTMLDeclaration |
The above is the detailed content of Detailed explanation of a perfect HTML parsing engine (Jumony). For more information, please follow other related articles on the PHP Chinese website!