public class DOMHelper
extends java.lang.Object
Constructor and Description |
---|
DOMHelper() |
DOMHelper(java.io.Writer out) |
Modifier and Type | Method and Description |
---|---|
static org.w3c.dom.Node |
findNodeByAttributes(org.w3c.dom.Node root,
java.util.Map<java.lang.String,java.lang.String> attributes)
Finds the node that matches the given attributes starting at the given node
|
static org.w3c.dom.Element |
findNodeByID(org.w3c.dom.Document doc,
java.lang.String id)
Finds the node with the given ID in the given DOM tree
|
void |
followNode(org.w3c.dom.Node node,
int tabSize)
Prints the given DOM tree to the provided out stream.
|
static java.util.Map<java.lang.String,java.lang.String> |
getAttributeMap(org.w3c.dom.Node node,
java.lang.String[] atts)
Returns a map of the attributes from the node that match the attributes in the given list.
|
java.lang.String |
getNodeAsString(org.w3c.dom.Node node,
int tabSize)
Returns the given node as a formatted string
|
static void |
printNode(org.w3c.dom.Node node)
Prints the given DOM tree to standard out
|
void |
printNode(org.w3c.dom.Node node,
int tabSize)
Prints a single node to the provided stream
|
public static org.w3c.dom.Element findNodeByID(org.w3c.dom.Document doc, java.lang.String id)
doc
- the root of the DOM tree to searchid
- the desired node's idpublic static org.w3c.dom.Node findNodeByAttributes(org.w3c.dom.Node root, java.util.Map<java.lang.String,java.lang.String> attributes)
root
- The DOM tree to search inattributes
- the attributes of the desired nodepublic static java.util.Map<java.lang.String,java.lang.String> getAttributeMap(org.w3c.dom.Node node, java.lang.String[] atts)
node
- the node to get the attributes fromatts
- the desired attributes to matchpublic static void printNode(org.w3c.dom.Node node)
node
- The root of the tree to printpublic void printNode(org.w3c.dom.Node node, int tabSize)
node
- the node to printtabSize
- the desired tab sizepublic void followNode(org.w3c.dom.Node node, int tabSize)
node
- the root of the tree to printtabSize
- The starting tab size for the nodespublic java.lang.String getNodeAsString(org.w3c.dom.Node node, int tabSize)
node
- the nodetabSize
- the desired tab size