public final class XMLUtilities extends Object implements Serializable
Modifier and Type | Method and Description |
---|---|
static Node |
createNodeFromText(String xmlText)
Create an xml Node using the passed in text.
|
static List<Node> |
findByExpression(String expression,
Node searchNode)
Return all nodes matching the passed in expression.
|
static Node |
findFirstByExpression(String expression,
Node searchNode)
Return the first node matching the passed in expression or null if none was found.
|
static Object |
fromXMLEscaped(String xml)
From xml escaped object.
|
static Map<String,String> |
getMap(NamedNodeMap attributes)
Gets map.
|
static Document |
readXmlFile(String srcFile)
Read an xml file.
|
static List<Node> |
toList(NodeList nodeList)
Turns a NodeList into a list.
|
static String |
toXMLEscaped(Object obj)
To xml escaped string.
|
public static String toXMLEscaped(Object obj)
obj
- the objpublic static Object fromXMLEscaped(String xml)
xml
- the xmlpublic static Node createNodeFromText(String xmlText) throws ParserConfigurationException, SAXException, IOException
xmlText
- xmlParserConfigurationException
- the parser configuration exceptionSAXException
- the sax exceptionIOException
- the io exceptionpublic static List<Node> findByExpression(String expression, Node searchNode) throws XPathExpressionException
Expression Description nodename Selects all nodes with the name "nodename" / Selects from the root node // Selects nodes in the document from the current node that match the selection no matter where they are . Selects the current node .. Selects the parent of the current node @ Selects attributes
expression
- search for this expressionsearchNode
- search this and all child nodesXPathExpressionException
- the x path expression exceptionpublic static Node findFirstByExpression(String expression, Node searchNode) throws XPathExpressionException
expression
- the expressionsearchNode
- the search nodeXPathExpressionException
- the x path expression exceptionpublic static Map<String,String> getMap(NamedNodeMap attributes)
attributes
- the attributespublic static List<Node> toList(NodeList nodeList)
nodeList
- the node listpublic static Document readXmlFile(String srcFile) throws ParserConfigurationException, SAXException, IOException
srcFile
- the src fileParserConfigurationException
- the parser configuration exceptionSAXException
- the sax exceptionIOException
- the io exceptionCopyright © 2004-2021. All Rights Reserved.