public class XmlUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<Object> |
asList(NodeList n) |
static XPathExpression |
compileXPath(String expression)
Compiles the given XPath expression.
|
static Document |
convertToXML(Object object)
Converts an object into an XML Document.
|
static Document |
convertToXML(String xmlContent)
Converts a String to an XML Document.
|
static NodeList |
evaluateXPath(Document xmlDocument,
String expression)
Returns a list of XML nodes that match the given XPath expression.
|
static NodeList |
evaluateXPath(String xmlContent,
String expression)
Returns a list of XML nodes that match the given XPath expression.
|
static List<Object> |
evaluateXPathAsObjectList(Document xmlDocument,
String expression)
Returns a list of Objects that match the given XPath expression.
|
static List<Object> |
evaluateXPathAsObjectList(String xmlContent,
String expression)
Returns a list of Objects that match the given XPath expression.
|
public static XPathExpression compileXPath(String expression) throws XPathExpressionException
expression - the XPath expression to be compiledXPathExpression object that can be used for further evaluationXPathExpressionException - if the expression cannot be compiledpublic static NodeList evaluateXPath(Document xmlDocument, String expression) throws XPathExpressionException
xmlDocument - the XML object to be evaluatedexpression - the XPath expression to be used for evaluationnull if
the XML Document is null.XPathExpressionException - if the expression cannot be evaluated.public static NodeList evaluateXPath(String xmlContent, String expression) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException
xmlContent - a string in XML format representing the content to be evaluatedexpression - the XPath expression to be used for evaluationnull if
the XML content is null.XPathExpressionException - if the expression cannot be compiled.SAXException - if any error occurs trying to parse the XML content stringIOException - if the input string cannot be convertedParserConfigurationException - if a DocumentBuilder cannot be createdpublic static List<Object> evaluateXPathAsObjectList(Document xmlDocument, String expression) throws XPathExpressionException
xmlDocument - the XML object to be evaluatedexpression - the XPath expression to be used for evaluationnull if the
XML Document is null.XPathExpressionException - If the expression cannot be compiled.public static List<Object> evaluateXPathAsObjectList(String xmlContent, String expression) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException
xmlContent - a string in XML format representing the content to be evaluatedexpression - the XPath expression to be used for evaluationnull if the XML
Document is null.XPathExpressionException - if the expression cannot be compiled.SAXException - if any parse error occurs trying to parse the XML content stringIOException - if the input string cannot be convertedParserConfigurationException - if a DocumentBuilder cannot be createdpublic static Document convertToXML(Object object) throws ParserConfigurationException, SAXException, IOException
object - the object to be converted in to an XML DocumentParserConfigurationException - if a DocumentBuilder cannot be createdSAXException - if any parse error occursIOException - if the input string cannot be convertedpublic static Document convertToXML(String xmlContent) throws ParserConfigurationException, SAXException, IOException
xmlContent - the object to be converted in to an XML DocumentParserConfigurationException - if a DocumentBuilder cannot be createdSAXException - if any parse error occursIOException - if the input string cannot be convertedCopyright © 2020. All rights reserved.