public class Dom4jUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private org.dom4j.Document |
doc
The doc.
|
| Constructor and Description |
|---|
Dom4jUtils() |
| Modifier and Type | Method and Description |
|---|---|
org.dom4j.Document |
create(java.io.File file)
Build the DOM based on the xml provided in the file.
|
org.dom4j.Document |
create(java.lang.String xmlString)
Build the DOM based on the xml string provided.
|
static org.dom4j.Element |
findNodeByFullName(org.dom4j.Element root,
java.lang.String fullname)
find a node with full name from children of the root.
|
org.dom4j.Element |
findNodeByFullName(java.lang.String fullname)
find a node with full name specified starting from root.
|
static void |
findNodesByFullName(org.dom4j.Element root,
java.lang.String fullname,
java.util.List<org.dom4j.Element> list)
find all the nodes with full name from the node.
|
java.util.List<org.dom4j.Element> |
findNodesByFullName(java.lang.String fullname)
find all the nodes with full name specifiec, start from root.
|
static org.dom4j.Element |
findParentByName(java.lang.String name,
org.dom4j.Element e)
find parent with name specified.
|
private java.lang.String |
findString(java.lang.String str)
find and return text of node.
|
org.dom4j.Document |
getDocument()
return doc.
|
static java.lang.String |
getFullName(org.dom4j.Element e)
Build the fully qualified name of an element.
|
protected static java.lang.String |
getFullyQualifiedName(org.dom4j.Element e)
Return an xml string in fully qualified form - e.g foo.bar.baz
|
org.dom4j.Element |
getRoot()
returns root node of DOM tree.
|
static void |
removeChildren(org.dom4j.Element root)
remove children from the node.
|
static org.dom4j.Element |
selectNode(org.dom4j.Element root,
java.lang.String elementName)
find a node with element name.
|
org.dom4j.Element |
selectNode(java.lang.String elementName)
find a node with element name - return the first one.
|
private static void |
selectNodes(org.dom4j.Element root,
java.lang.String elementName,
java.util.List<org.dom4j.Element> list)
find all the nodes with the name specified from the node.
|
java.util.List<org.dom4j.Element> |
selectNodes(java.lang.String elementName)
select all the nodes with the name specified, start from root node.
|
public org.dom4j.Document create(java.io.File file)
throws org.dom4j.DocumentException
file - the fileorg.dom4j.DocumentException - the document exceptionpublic org.dom4j.Document create(java.lang.String xmlString)
throws org.dom4j.DocumentException
xmlString - the xml stringorg.dom4j.DocumentException - the document exceptionpublic org.dom4j.Element getRoot()
public org.dom4j.Document getDocument()
private java.lang.String findString(java.lang.String str)
str - the strpublic static java.lang.String getFullName(org.dom4j.Element e)
e - - the Element to checkpublic org.dom4j.Element findNodeByFullName(java.lang.String fullname)
fullname - the fullnamepublic static org.dom4j.Element findNodeByFullName(org.dom4j.Element root,
java.lang.String fullname)
root - the rootfullname - the fullnamepublic java.util.List<org.dom4j.Element> findNodesByFullName(java.lang.String fullname)
fullname - the fullnamepublic static void findNodesByFullName(org.dom4j.Element root,
java.lang.String fullname,
java.util.List<org.dom4j.Element> list)
root - the rootfullname - the fullnamelist - the listpublic java.util.List<org.dom4j.Element> selectNodes(java.lang.String elementName)
elementName - the element nameprivate static void selectNodes(org.dom4j.Element root,
java.lang.String elementName,
java.util.List<org.dom4j.Element> list)
root - the rootelementName - the element namelist - the listprotected static java.lang.String getFullyQualifiedName(org.dom4j.Element e)
e - the epublic static org.dom4j.Element selectNode(org.dom4j.Element root,
java.lang.String elementName)
root - the rootelementName - the element namepublic static void removeChildren(org.dom4j.Element root)
root - the rootpublic org.dom4j.Element selectNode(java.lang.String elementName)
elementName - the element namepublic static org.dom4j.Element findParentByName(java.lang.String name,
org.dom4j.Element e)
name - the namee - the e