java.lang.Object
com.github.hypfvieh.util.xml.XmlUtil
Assorted static XML utility methods.
- Seit:
- 1.0.3 - 2018-01-10
- Autor:
- hypfvieh
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic NodeListapplyXpathExpressionToDocument(String _xpathExpression, Node _xmlDocumentOrNode) Applys a xpathExpression to a xml-Document and return aNodeListwith the results.convertToAttributeMap(NamedNodeMap _nodeMap) ConvertsNamedNodeMapto aLinkedHashMap<String,String>.convertToElementList(NodeList _nodeList) static booleanisElementType(Node _node) Shortcut for checking if given node is of typeElement.static DocumentparseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) Read the given string as XML document.static DocumentparseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware) Loads XML from string and uses referenced XSD to validate the content.static DocumentparseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) Loads XML from string and uses referenced XSD to validate the content.static voidprintDocument(Node _docOrNode, OutputStream _outStream) static Element
-
Methodendetails
-
isElementType
Shortcut for checking if given node is of typeElement.- Parameter:
_node- node- Gibt zurück:
- true if
Element, false otherwise
-
toElement
-
applyXpathExpressionToDocument
public static NodeList applyXpathExpressionToDocument(String _xpathExpression, Node _xmlDocumentOrNode) throws IOException Applys a xpathExpression to a xml-Document and return aNodeListwith the results.- Parameter:
_xpathExpression- xpath expression_xmlDocumentOrNode- document or node- Gibt zurück:
NodeList- Löst aus:
IOException- on error
-
parseXmlString
public static Document parseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) throws IOException Read the given string as XML document.- Parameter:
_xmlStr- xml string_validating- boolean_namespaceAware- boolean- Gibt zurück:
Document- Löst aus:
IOException- on error
-
convertToElementList
- Parameter:
_nodeList- collection of nodes- Gibt zurück:
- list of elements
-
convertToAttributeMap
ConvertsNamedNodeMapto aLinkedHashMap<String,String>.- Parameter:
_nodeMap- node map- Gibt zurück:
LinkedHashMap, maybe empty but never null
-
parseXmlStringWithXsdValidation
public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException Loads XML from string and uses referenced XSD to validate the content.- Parameter:
_xmlStr- string to validate_namespaceAware- take care of namespace_errorHandler- e.g.XmlErrorHandlers.XmlErrorHandlerQuietorXmlErrorHandlers.XmlErrorHandlerRuntimeException- Gibt zurück:
- Document
- Löst aus:
IOException- on error
-
parseXmlStringWithXsdValidation
public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware) throws IOException Loads XML from string and uses referenced XSD to validate the content. This method will useXmlErrorHandlers.XmlErrorHandlerQuietto suppress all errors/warnings when validating.- Parameter:
_xmlStr- string to validate_namespaceAware- take care of namespace- Gibt zurück:
- Document
- Löst aus:
IOException- on error
-
printDocument
- Parameter:
_docOrNode-DocumentorNodeobject_outStream-OutputStreamto print on- Löst aus:
IOException- on error
-