public class XmlUtil extends Object
文档地址:
http://www.w3school.com.cn/xpath/index.asp
| 限定符和类型 | 类和说明 |
|---|---|
private static class |
XmlUtil.XmlHelperHolder
内部类单例
|
| 限定符和类型 | 字段和说明 |
|---|---|
private Document |
doc |
private XPath |
path |
private static boolean |
preventedXXE |
| 限定符 | 构造器和说明 |
|---|---|
private |
XmlUtil(InputSource inputSource) |
| 限定符和类型 | 方法和说明 |
|---|---|
private static XmlUtil |
create(InputSource inputSource) |
private Object |
evalXpath(String expression,
Object item,
QName returnType) |
Boolean |
getBoolean(Object node,
String expression)
获取
|
Boolean |
getBoolean(String expression)
获取Boolean
|
private static DocumentBuilderFactory |
getDocumentBuilderFactory() |
Node |
getNode(Object node,
String expression)
获取某个节点
|
Node |
getNode(String expression)
获取某个节点
|
NodeList |
getNodeList(Object node,
String expression)
获取子节点
|
NodeList |
getNodeList(String expression)
获取子节点
|
Number |
getNumber(Object node,
String expression)
获取
|
Number |
getNumber(String expression)
获取Number
|
String |
getString(Object node,
String expression)
获取String
|
String |
getString(String expression)
获取String
|
private static XPathFactory |
getXpathFactory() |
static XmlUtil |
of(InputStream is) |
static XmlUtil |
of(String xmlStr) |
private static void |
preventXxe(DocumentBuilderFactory dbf)
preventXXE
|
Map<String,String> |
toMap()
针对没有嵌套节点的简单处理
|
private final XPath path
private final Document doc
private static volatile boolean preventedXXE
private XmlUtil(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException
private static XmlUtil create(InputSource inputSource)
public static XmlUtil of(InputStream is)
public String getString(Object node, String expression)
node - 节点expression - 相对于node的路径public Boolean getBoolean(Object node, String expression)
node - 节点expression - 相对于node的路径public Number getNumber(Object node, String expression)
node - 节点expression - 相对于node的路径public Node getNode(Object node, String expression)
node - 节点expression - 路径public NodeList getNodeList(Object node, String expression)
node - 节点expression - 相对于node的路径private static DocumentBuilderFactory getDocumentBuilderFactory() throws ParserConfigurationException
private static void preventXxe(DocumentBuilderFactory dbf) throws ParserConfigurationException
dbf - ParserConfigurationExceptionprivate static XPathFactory getXpathFactory()
Copyright © 2024. All rights reserved.