public class XMLUtils extends Object
| Constructor and Description |
|---|
XMLUtils() |
| Modifier and Type | Method and Description |
|---|---|
static NodeList |
evaluateXPath(Node context,
String expr,
Map<String,String> namespaceBindings)
Evaluates an XPath 1.0 expression using the given context and returns the result as a node set.
|
static Object |
evaluateXPath(Node context,
String expr,
Map<String,String> namespaceBindings,
QName returnType)
Evaluates an XPath expression using the given context and returns the result as the specified type.
|
static int |
parseAsInteger(Node context,
String xpath)
Returns the selected value
|
static String |
writeNodeToString(Node node)
Writes the content of a DOM Node to a string.
|
public static String writeNodeToString(Node node)
node - The DOM Node to be serialized.public static NodeList evaluateXPath(Node context, String expr, Map<String,String> namespaceBindings) throws XPathExpressionException
context - The context node.expr - An XPath expression.namespaceBindings - A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI
(key) to a prefix (value). Standard bindings do not need to be declared (see
NamespaceBindings.withStandardBindings().XPathExpressionException - If the expression cannot be evaluated for any reason.public static Object evaluateXPath(Node context, String expr, Map<String,String> namespaceBindings, QName returnType) throws XPathExpressionException
Note: The Saxon implementation supports XPath 2.0 expressions when using the JAXP XPath APIs (the default implementation will throw an exception).
context - The context node.expr - An XPath expression.namespaceBindings - A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI
(key) to a prefix (value). Standard bindings do not need to be declared (see
NamespaceBindings.withStandardBindings().returnType - The desired return type (as declared in XPathConstants ).XPathExpressionException - If the expression cannot be evaluated for any reason.public static int parseAsInteger(Node context, String xpath) throws XPathExpressionException
context - The context node.xpath - An XPath expression evaluating to an integer value.XPathExpressionException - If the expression cannot be evaluated for any reason.Copyright © 2019 Open Geospatial Consortium. All rights reserved.