parser library
This library has a parser for HTML5 documents, that lets you parse HTML easily from a script or server side application:
import 'package:html/parser.dart' show parse;
import 'package:html/dom.dart';
main() {
var document = parse(
'<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!');
print(document.outerHtml);
}
The resulting document you get back has a DOM-like API for easy tree traversal and manipulation.
Classes
- AfterAfterBodyPhase
- AfterAfterFramesetPhase
- AfterBodyPhase
- AfterFramesetPhase
- AfterHeadPhase
- BeforeHeadPhase
- BeforeHtmlPhase
- HtmlParser
- Parser for HTML, which generates a tree structure from a stream of (possibly malformed) characters.
- InBodyPhase
- InCaptionPhase
- InCellPhase
- InColumnGroupPhase
- InForeignContentPhase
- InFramesetPhase
- InHeadPhase
- InitialPhase
- InRowPhase
- InSelectInTablePhase
- InSelectPhase
- InTableBodyPhase
- InTablePhase
- InTableTextPhase
- Phase
- Base class for helper object that implements each phase of processing.
- TextPhase
Functions
-
getElementNameTuple(
Element e) → (String, String?) - Convenience function to get the pair of namespace and localName.
-
parse(
dynamic input, {String? encoding, bool generateSpans = false, String? sourceUrl}) → Document - Parse an html5 document into a tree.
-
parseFragment(
dynamic input, {String container = 'div', String? encoding, bool generateSpans = false, String? sourceUrl}) → DocumentFragment - Parse an html5 document fragment into a tree.
Typedefs
- TokenProccessor = Token Function(Token token)
Exceptions / Errors
- ParseError
- Error in parsed document.