public abstract class DOMUtils extends Object
Constructor and Description |
---|
DOMUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copyAttributes(Element destElement,
Element srcElement)
Copy attributes between elements
|
static Element |
createElement(String localPart,
String prefix,
String uri,
Document doc)
Create an Element for a given name, prefix and uri
|
static Map<QName,String> |
getAttributes(Element el)
Get the attributes as Map<QName, String>
|
static String |
getAttributeValue(Element el,
QName attrName)
Get the value from the given attribute
|
static String |
getAttributeValue(Element el,
String attrName)
Get the value from the given attribute
|
static boolean |
getAttributeValueAsBoolean(Element el,
QName attrName)
Get the boolean value from the given attribute
|
static boolean |
getAttributeValueAsBoolean(Element el,
String attrName)
Get the boolean value from the given attribute
|
static Integer |
getAttributeValueAsInteger(Element el,
QName attrName)
Get the integer value from the given attribute
|
static Integer |
getAttributeValueAsInteger(Element el,
String attrName)
Get the integer value from the given attribute
|
static QName |
getAttributeValueAsQName(Element el,
QName attrName)
Get the qname value from the given attribute
|
static QName |
getAttributeValueAsQName(Element el,
String attrName)
Get the qname value from the given attribute
|
static Iterator<Element> |
getChildElements(Node node)
Gets child elements
|
static Iterator<Element> |
getChildElements(Node node,
QName nodeName)
Gets the child element for a given qname
|
static Iterator<Element> |
getChildElements(Node node,
QName nodeName,
boolean recursive)
Gets the child element for a given qname
|
static Iterator<Element> |
getChildElements(Node node,
String nodeName)
Gets the child elements for a given local name without namespace
|
static Iterator<Element> |
getChildElements(Node node,
String nodeName,
boolean recursive)
Gets the child elements for a given local name without namespace
|
static List<Element> |
getChildElementsAsList(Node node,
QName nodeName) |
static List<Element> |
getChildElementsAsList(Node node,
QName nodeName,
boolean recursive) |
static List<Element> |
getChildElementsAsList(Node node,
String nodeName) |
static List<Element> |
getChildElementsAsList(Node node,
String nodeName,
boolean recursive) |
static QName |
getElementQName(Element el)
Get the qname of the given node.
|
static Element |
getFirstChildElement(Node node)
Gets the first child element
|
static Element |
getFirstChildElement(Node node,
boolean recursive)
Gets the first child element
|
static Element |
getFirstChildElement(Node node,
QName nodeName)
Gets the first child element for a given qname
|
static Element |
getFirstChildElement(Node node,
QName nodeName,
boolean recursive)
Gets the first child element for a given qname
|
static Element |
getFirstChildElement(Node node,
String nodeName)
Gets the first child element for a given local name without namespace
|
static Element |
getFirstChildElement(Node node,
String nodeName,
boolean recursive)
Gets the first child element for a given local name without namespace
|
static Element |
getParentElement(Node node)
Gets parent element or null if there is none
|
static String |
getTextContent(Node node)
Get the concatenated text content, or null.
|
static boolean |
hasChildElements(Node node)
True if the node has child elements
|
static boolean |
hasTextChildNodesOnly(Node node)
True if the node has text child elements only
|
static Element |
parse(InputSource source,
DocumentBuilder builder)
Parse the given input source and return the root Element
|
static Element |
parse(InputStream xmlStream,
DocumentBuilder builder)
Parse the given XML stream and return the root Element
|
static Element |
parse(String xmlString,
DocumentBuilder builder)
Parse the given XML string and return the root Element
|
static QName |
resolveQName(Element el,
String qualifiedName)
Transform the given qualified name into a QName
|
static Element |
sourceToElement(Source source,
DocumentBuilder builder) |
public static QName getElementQName(Element el)
el
- nodepublic static QName resolveQName(Element el, String qualifiedName)
el
- nodequalifiedName
- qualified namepublic static String getAttributeValue(Element el, String attrName)
el
- elementattrName
- attribute namepublic static String getAttributeValue(Element el, QName attrName)
el
- elementattrName
- attribute namepublic static QName getAttributeValueAsQName(Element el, String attrName)
el
- elementattrName
- attribute namepublic static QName getAttributeValueAsQName(Element el, QName attrName)
el
- elementattrName
- attribute namepublic static boolean getAttributeValueAsBoolean(Element el, String attrName)
el
- elementattrName
- attribute namepublic static boolean getAttributeValueAsBoolean(Element el, QName attrName)
el
- elementattrName
- attribute namepublic static Integer getAttributeValueAsInteger(Element el, String attrName)
el
- elementattrName
- attribute namepublic static Integer getAttributeValueAsInteger(Element el, QName attrName)
el
- elementattrName
- attribute namepublic static Map<QName,String> getAttributes(Element el)
el
- elementpublic static void copyAttributes(Element destElement, Element srcElement)
destElement
- elementsrcElement
- elementpublic static boolean hasTextChildNodesOnly(Node node)
node
- start nodepublic static boolean hasChildElements(Node node)
node
- start nodepublic static Iterator<Element> getChildElements(Node node)
node
- start nodepublic static String getTextContent(Node node)
node
- nodepublic static Element getFirstChildElement(Node node)
node
- start nodepublic static Element getFirstChildElement(Node node, boolean recursive)
node
- childrecursive
- recurse flagpublic static Element getFirstChildElement(Node node, String nodeName)
node
- childnodeName
- namepublic static Element getFirstChildElement(Node node, String nodeName, boolean recursive)
node
- childnodeName
- namerecursive
- recurse flagpublic static Element getFirstChildElement(Node node, QName nodeName)
node
- childnodeName
- namepublic static Element getFirstChildElement(Node node, QName nodeName, boolean recursive)
node
- childnodeName
- namerecursive
- recurse flagpublic static Iterator<Element> getChildElements(Node node, String nodeName)
node
- childnodeName
- namepublic static Iterator<Element> getChildElements(Node node, String nodeName, boolean recursive)
node
- childnodeName
- namerecursive
- recurse flagpublic static Iterator<Element> getChildElements(Node node, QName nodeName)
node
- childnodeName
- namepublic static Iterator<Element> getChildElements(Node node, QName nodeName, boolean recursive)
node
- childnodeName
- namerecursive
- recurse flagpublic static List<Element> getChildElementsAsList(Node node, String nodeName)
public static List<Element> getChildElementsAsList(Node node, String nodeName, boolean recursive)
public static List<Element> getChildElementsAsList(Node node, QName nodeName)
public static List<Element> getChildElementsAsList(Node node, QName nodeName, boolean recursive)
public static Element getParentElement(Node node)
node
- childpublic static Element sourceToElement(Source source, DocumentBuilder builder) throws IOException
IOException
public static Element parse(String xmlString, DocumentBuilder builder) throws IOException
xmlString
- string to be parsedbuilder
- document builderIOException
- exceptionpublic static Element parse(InputStream xmlStream, DocumentBuilder builder) throws IOException
xmlStream
- input streambuilder
- document builderIOException
- exceptionpublic static Element parse(InputSource source, DocumentBuilder builder) throws IOException
source
- input sourcebuilder
- document builderIOException
- exceptionCopyright © 2017 JBoss by Red Hat. All rights reserved.