Top Description Constructors Methods
org.freedesktop.dbus.utils

public final Class XmlUtil

extends Object
Class Inheritance
Imports
org.w3c.dom.*, java.io.ByteArrayInputStream, .IOException, java.nio.charset.StandardCharsets, java.util.ArrayList, .LinkedHashMap, .List, .Map, javax.xml.parsers.DocumentBuilderFactory, javax.xml.xpath.*

Assorted static XML utility methods.
Author
hypfvieh

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static NodeList

Returns:

NodeList
applyXpathExpressionToDocument
(String
xpath expression
_xpathExpression
,
Node
document or node
_xmlDocumentOrNode
)

Applys a xpathExpression to a xml-Document and return a NodeList with the results.

public static Map<String, String>

Returns:

LinkedHashMap, maybe empty but never null
convertToAttributeMap
(NamedNodeMap
node map
_nodeMap
)

Converts NamedNodeMap to a LinkedHashMap<String,String>.

public static List<Element>

Returns:

list of elements
convertToElementList
(NodeList
collection of nodes
_nodeList
)

Convert a NodeList to a Java List of Elements.

public static boolean

Returns:

true if Element, false otherwise
isElementType
(Node
node
_node
)

Shortcut for checking if given node is of type Element.

public static Document
parseXmlString(String
xml string
_xmlStr
,
boolean
boolean
_validating
,
boolean
boolean
_namespaceAware
)

Read the given string as XML document.

public static Element

Returns:

Element or null if given Node is not Element subtype
toElement
(Node
node
_node
)

Checks and converts given Node to Element if possible.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

XmlUtilback to summary
private XmlUtil()

Method Detail

applyXpathExpressionToDocumentback to summary
public static NodeList applyXpathExpressionToDocument(String _xpathExpression, Node _xmlDocumentOrNode) throws IOException

Applys a xpathExpression to a xml-Document and return a NodeList with the results.

Parameters
_xpathExpression:String

xpath expression

_xmlDocumentOrNode:Node

document or node

Returns:NodeList

NodeList

Exceptions
IOException:
on error
convertToAttributeMapback to summary
public static Map<String, String> convertToAttributeMap(NamedNodeMap _nodeMap)

Converts NamedNodeMap to a LinkedHashMap<String,String>.

Parameters
_nodeMap:NamedNodeMap

node map

Returns:Map<String, String>

LinkedHashMap, maybe empty but never null

convertToElementListback to summary
public static List<Element> convertToElementList(NodeList _nodeList)

Convert a NodeList to a Java List of Elements.

Parameters
_nodeList:NodeList

collection of nodes

Returns:List<Element>

list of elements

isElementTypeback to summary
public static boolean isElementType(Node _node)

Shortcut for checking if given node is of type Element.

Parameters
_node:Node

node

Returns:boolean

true if Element, false otherwise

parseXmlStringback to summary
public static Document parseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) throws IOException

Read the given string as XML document.

Parameters
_xmlStr:String

xml string

_validating:boolean

boolean

_namespaceAware:boolean

boolean

Returns:Document

org.w3c.dom.Document

Exceptions
IOException:
on error
toElementback to summary
public static Element toElement(Node _node)

Checks and converts given Node to Element if possible.

Parameters
_node:Node

node

Returns:Element

Element or null if given Node is not Element subtype