Void readFromString(ElementTree location, String input, WhiteList safety, Doctype doctype)
Arguments
location: The location in the document to append the converted Stringinput: The String to convertsafety: The allowed elements and attributesdoctype: The document type of the input string. This is independent of the document type of the document and controls certain aspects of parsing - for example, if the doctype isHTML4Strict, the end tags forportdelements may be omitted, and the code will be case-insensitive.
Usage
Convert a String to HTML. An Exception will be thrown if the parser cannot construct an unambiguous tree from the string, and it is considerably less forgiving than the parsers in most web browsers. (On the other hand, it's a bit more forgiving in places than a strict XML parser, especially if the HTML4Strict doctype is used). As usual, parsing with XHTML strictness will be quicker.
Read the WhiteList documentation for important information on safety when converting these Strings
If you need to read poor-quality HTML, you can use the TagSoup setting for the doctype parameter, but this will be somewhat slower - if you're writing the HTML yourself it's much more efficient to write good quality code in the first place. This parsing model rarely throws an Exception (though it is still possible on very poor code)
str = "<p>This is a <strong>crucial</strong> paragraph</p>";
readFromString(parent,str,AllElements(Safe),HTML4Strict);