public class DomUtil extends Object
| Modifier and Type | Method and Description | 
|---|---|
static String | 
formatHtml(Node node)
Pretty prints the given HTML node. 
 | 
static void | 
setAttribute(Element element,
            String name,
            String value)
Assumes the implementation outputs the attribute as a double-quoted attribute. 
 | 
static void | 
setJs(Document doc,
     Element element,
     String text)
Similar to  
setText(Document, Element, String), but assumes the text to be set is JavaScript. | 
static void | 
setText(Document doc,
       Element element,
       String text)
Adds the given text to the node as a child, escaping according to HTML rules. 
 | 
public static String formatHtml(Node node) throws IOException
node - the node to format to htmlIOException - Should not happen as ByteArrayOutputStream does not throw.public static void setText(Document doc, Element element, String text)
doc - the document for which the node should be addedelement - the element under which the text node should be appendedtext - the text of the textnodepublic static void setJs(Document doc, Element element, String text)
setText(Document, Element, String), but assumes the text to be set is JavaScript. The
 text content of a script tag is CDATA, the string 
doc - the document for which the node should be addedelement - the element under which the node should be appendedtext - the javascript to set to the nodepublic static void setAttribute(Element element, String name, String value)
element - Element on which to set an attribute.name - Attribute name to set.value - Attribute value to set.Copyright © 2019 XIMA MEDIA GmbH. All rights reserved.