public final class XmlUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static NodeList |
applyXpathExpressionToDocument(String _xpathExpression,
Node _xmlDocumentOrNode)
Applys a xpathExpression to a xml-Document and return a
NodeList with the results. |
static Map<String,String> |
convertToAttributeMap(NamedNodeMap _nodeMap)
Converts
NamedNodeMap to a LinkedHashMap<String,String>. |
static List<Element> |
convertToElementList(NodeList _nodeList)
|
static boolean |
isElementType(Node _node)
Shortcut for checking if given node is of type
Element. |
static Document |
parseXmlString(String _xmlStr,
boolean _validating,
boolean _namespaceAware)
Read the given string as XML document.
|
static Document |
parseXmlStringWithXsdValidation(String _xmlStr,
boolean _namespaceAware)
Loads XML from string and uses referenced XSD to validate the content.
|
static Document |
parseXmlStringWithXsdValidation(String _xmlStr,
boolean _namespaceAware,
ErrorHandler _errorHandler)
Loads XML from string and uses referenced XSD to validate the content.
|
static void |
printDocument(Node _docOrNode,
OutputStream _outStream)
|
static Element |
toElement(Node _node)
|
public static boolean isElementType(Node _node)
Element._node - nodeElement, false otherwisepublic static NodeList applyXpathExpressionToDocument(String _xpathExpression, Node _xmlDocumentOrNode) throws IOException
NodeList with the results._xpathExpression - xpath expression_xmlDocumentOrNode - document or nodeNodeListIOException - on errorpublic static Document parseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) throws IOException
_xmlStr - xml string_validating - boolean_namespaceAware - booleanDocumentIOException - on errorpublic static List<Element> convertToElementList(NodeList _nodeList)
_nodeList - collection of nodespublic static Map<String,String> convertToAttributeMap(NamedNodeMap _nodeMap)
NamedNodeMap to a LinkedHashMap<String,String>._nodeMap - node mapLinkedHashMap, maybe empty but never nullpublic static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException
_xmlStr - string to validate_namespaceAware - take care of namespace_errorHandler - e.g. XmlErrorHandlers.XmlErrorHandlerQuiet or XmlErrorHandlers.XmlErrorHandlerRuntimeExceptionIOException - on errorpublic static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware) throws IOException
XmlErrorHandlers.XmlErrorHandlerQuiet to suppress all errors/warnings when validating._xmlStr - string to validate_namespaceAware - take care of namespaceIOException - on errorpublic static void printDocument(Node _docOrNode, OutputStream _outStream) throws IOException
_docOrNode - Document or Node object_outStream - OutputStream to print onIOException - on errorCopyright © 2018. All rights reserved.