Package org.apache.commons.modeler.util
Class DomUtil
java.lang.Object
org.apache.commons.modeler.util.DomUtil
Few simple utils to read DOM
- Author:
- Costin Manolache
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NodefindChildWithAtt(Node parent, String elemName, String attName, String attVal) Find the first direct child with a given attribute.static StringgetAttribute(Node element, String attName) static NodeGet the first direct child with a given typestatic NodeGet the first element child.static StringgetChildContent(Node parent, String name) Get the first child's content ( ie it's included TEXT node ).static StringgetContent(Node n) Get the trimed text content of a node or null if there is no textstatic NodeGet the next sibling with the same name and typestatic NodeReturn the next sibling with a given name and typestatic DocumentreadXml(InputStream is) Read XML as DOM.static voidremoveAttribute(Node node, String attName) static voidsetAttribute(Node node, String attName, String val) static voidsetAttributes(Object o, Node parent) static voidSet or replace the text valuestatic voidwriteXml(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
-