Search in sources :

Example 1 with XMLDocument

use of org.loboevolution.html.js.xml.XMLDocument in project LoboEvolution by LoboEvolution.

the class DOMParserImpl method parseFromString.

/**
 * {@inheritDoc}
 */
@Override
public Document parseFromString(String html, String type) {
    Element element = document.createElement("DIV");
    element.setInnerHTML(html);
    if (!"text/html".equals(type) && !"text/xml".equals(type) && !"application/xml".equals(type) && !"application/xhtml+xml".equals(type) && !"image/svg+xml".equals(type)) {
        throw Context.reportRuntimeError("Invalid 'type' parameter: " + type);
    }
    XMLDocument document = new XMLDocument();
    document.loadXML(element.getInnerHTML());
    return document;
}
Also used : Element(org.loboevolution.html.node.Element) XMLDocument(org.loboevolution.html.js.xml.XMLDocument)

Aggregations

XMLDocument (org.loboevolution.html.js.xml.XMLDocument)1 Element (org.loboevolution.html.node.Element)1