class DetectsXMLParsedAsHTML(object): (source)
Known subclasses: bs4.builder._htmlparser.BeautifulSoupHTMLParser
A mixin class for any class (a TreeBuilder, or some class used by a TreeBuilder) that's in a position to detect whether an XML document is being incorrectly parsed as HTML, and issue an appropriate warning. This requires being able to observe an incoming processing instruction that might be an XML declaration, and also able to observe tags as they're opened. If you can't do that for a given TreeBuilder, there's a less reliable implementation based on examining the raw markup.
Class Method | warn |
Perform a check on some markup to see if it looks like XML that's not XHTML. If so, issue a warning. |
Constant | LOOKS |
Undocumented |
Constant | LOOKS |
Undocumented |
Constant | XML |
Undocumented |
Constant | XML |
Undocumented |
Class Method | _warn |
Issue a warning about XML being parsed as HTML. |
Method | _document |
Call this method when encountering an XML declaration, or a "processing instruction" that might be an XML declaration. |
Method | _initialize |
Call this method before parsing a document. |
Method | _root |
Call this when you encounter the document's root tag. |
Instance Variable | _first |
Undocumented |
Instance Variable | _root |
Undocumented |
Perform a check on some markup to see if it looks like XML that's not XHTML. If so, issue a warning. This is much less reliable than doing the check while parsing, but some of the tree builders can't do that. :return: True if the markup looks like non-XHTML XML, False otherwise.
Call this method when encountering an XML declaration, or a "processing instruction" that might be an XML declaration.