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) |
static Map<String,String> |
getMap(NamedNodeMap attributes) |
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) |
public static Node createNodeFromText(String xmlText) throws ParserConfigurationException, SAXException, IOException
xmlText - ParserConfigurationExceptionSAXExceptionIOExceptionpublic 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 expressionnodes - search this and all child nodesXPathExpressionExceptionpublic static Node findFirstByExpression(String expression, Node searchNode) throws XPathExpressionException
expression - searchNode - XPathExpressionExceptionpublic static Map<String,String> getMap(NamedNodeMap attributes)
attributes - public static List<Node> toList(NodeList nodeList)
nodeList - public static Document readXmlFile(String srcFile) throws ParserConfigurationException, SAXException, IOException
srcFile - ParserConfigurationExceptionSAXExceptionIOExceptionCopyright © 2004-2017. All Rights Reserved.