Package org.apache.commons.modeler.util
Class DomUtil
java.lang.Object
org.apache.commons.modeler.util.DomUtil
Few simple utils to read DOM
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Node
findChildWithAtt
(Node parent, String elemName, String attName, String attVal) Find the first direct child with a given attribute.static String
getAttribute
(Node element, String attName) static Node
Get the first direct child with a given typestatic Node
Get the first element child.static String
getChildContent
(Node parent, String name) Get the first child's content ( ie it's included TEXT node ).static String
getContent
(Node n) Get the trimed text content of a node or null if there is no textstatic Node
Get the next sibling with the same name and typestatic Node
Return the next sibling with a given name and typestatic Document
readXml
(InputStream is) Read XML as DOM.static void
removeAttribute
(Node node, String attName) static void
setAttribute
(Node node, String attName, String val) static void
setAttributes
(Object o, Node parent) static void
Set or replace the text valuestatic void
writeXml
(Node n, OutputStream os)
-
Field Details
-
log
private static org.apache.commons.logging.Log log
-
-
Constructor Details
-
DomUtil
public DomUtil()
-
-
Method Details
-
getContent
Get the trimed text content of a node or null if there is no text -
getChild
Get the first element child.- Parameters:
parent
- lookup direct childsname
- name of the element. If null return the first element.
-
getAttribute
-
setAttribute
-
removeAttribute
-
setText
Set or replace the text value -
findChildWithAtt
Find the first direct child with a given attribute.- Parameters:
parent
-elemName
- name of the element, or null for anyattName
- attribute we're looking forattVal
- attribute value or null if we just want any
-
getChildContent
Get the first child's content ( ie it's included TEXT node ). -
getChild
Get the first direct child with a given type -
getNext
Get the next sibling with the same name and type -
getNext
Return the next sibling with a given name and type -
setAttributes
-
readXml
public static Document readXml(InputStream is) throws SAXException, IOException, ParserConfigurationException Read XML as DOM. -
writeXml
- Throws:
TransformerException
-