public final class XmlNodeHelper extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
getAndCheckNodeText(org.dom4j.Node node,
String nodeName)
检查和获取节点文本,会检查节点是否为空,如果节点为空,则抛出异常.
|
static String[] |
getBothCheckNodeText(org.dom4j.Node node)
检查和获取开始和结束文本的内容,返回一个数组,会检查两个节点是否为空,如果都为空,则抛出异常.
|
static org.dom4j.Document |
getDocument(String xmlPath)
读取xml文件为dom4j的Docment文档.
|
static String |
getNodeAttrText(org.dom4j.Node node,
String attrName)
获取节点文本.
|
static org.dom4j.Node |
getNodeBySpaceAndId(String nameSpace,
String zealotId)
根据xml文件的nameSpace及zealot节点id值获取对应的第一个dom4j节点.
|
static String |
getNodeText(org.dom4j.Node node)
获取xml节点的文本值,如果对象是空的,则转为空字符串.
|
static org.dom4j.Node |
getZealotNodeById(org.dom4j.Document doc,
String id)
根据xml文件docment中的zealot节点id值获取对应的第一个节点.
|
static String |
getZealotXmlNameSpace(String xmlPath)
根据xml文件的路径判断该xml文件是否是zealot xml文件(简单判断是否有'zealots'根节点即可),如果是则返回nameSpace.
|
public static org.dom4j.Document getDocument(String xmlPath)
xmlPath - 定位xml文件的路径,如:com/blinkfox/test.xmlpublic static org.dom4j.Node getNodeBySpaceAndId(String nameSpace, String zealotId)
nameSpace - xml文件对应命名空间zealotId - ZealotIdpublic static String getZealotXmlNameSpace(String xmlPath)
xmlPath - xml路径public static org.dom4j.Node getZealotNodeById(org.dom4j.Document doc,
String id)
使用xPath语法获取第一个符合条件的节点.
doc - docment文档id - zealotIdpublic static String getNodeText(org.dom4j.Node node)
node - dom4j节点public static String getNodeAttrText(org.dom4j.Node node, String attrName)
node - dom4j节点attrName - 节点属性public static String getAndCheckNodeText(org.dom4j.Node node, String nodeName)
node - dom4j节点nodeName - 节点名称public static String[] getBothCheckNodeText(org.dom4j.Node node)
node - dom4j节点Copyright © 2018. All rights reserved.