类 XmlUtil
java.lang.Object
com.sh.common.util.XmlUtil
Title: 解析XML文件类
Copyright: Copyright JXC(c) 2009-2010
Company:首亨软件(重庆)有限公司
-
字段概要
字段 -
方法概要
修饰符和类型方法说明static InputStreamfindDtdByResource(String dtdFileName) 从资源JAR包中查找static InputStreamfindDtdFile(String dtdFileName) 从本地文件中查找static List<org.jdom2.Element>getAllChildren(org.jdom2.Element e) 获取指定结点下的所有子结点getAllProperty(org.jdom2.Element e) 获取指定结点的属性static StringgetAttribute(org.jdom2.Element e, String attributeName) 获取指定结点的属性 ,没有找到该对象时返回空字符串static org.jdom2.ElementgetChildByName(org.jdom2.Element e, String childName) static List<org.jdom2.Element>getChildrenByName(org.jdom2.Element e, String childName) 获取指定结点的指定名称的子结点static StringgetChildText(org.jdom2.Element e, String name) 获取某一子结点的文本描述static List<org.jdom2.Element>getNodeByPath(org.jdom2.Element root, String path) 根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点static StringgetNodeByPathAttr(org.jdom2.Element root, String path, String attrName) 根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点static org.jdom2.ElementgetNodeByPathElement(org.jdom2.Element root, String path) 根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点static StringgetNodeByPathText(org.jdom2.Element root, String path) 根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点static StringgetText(org.jdom2.Element e) 获取结点描述static booleanhasChildren(org.jdom2.Element e) 是否有子结点static org.jdom2.DocumentparseInputXMLDoc(String xmlInput) 将XML格式的字符串转化为Document对象static org.jdom2.ElementparseInputXMLString(String xmlInput) 加载、解析XML格式的字符串static String解析成XML字符串static org.jdom2.Document将XML文件输入流转化为一个文档对象static org.jdom2.DocumentparseXMLFileToDoc(String path) 加载、解析XML文件static org.jdom2.DocumentparseXMLFileToDoc(String path, String dtdName) 加载、解析XML文件,并查找本地的DTD进行效验static org.jdom2.Document加载、解析XML文件static org.jdom2.Element将XML文件输入流转化为文档结点对象static org.jdom2.ElementparseXMLFileToEle(String path) 加载、解析XML文件static Stringstatic String输出XML格式字符串static StringtoString(org.jdom2.Element el)
-
字段详细资料
-
log4j
protected static org.apache.logging.log4j.Logger log4j
-
-
方法详细资料
-
parseInputXMLString
加载、解析XML格式的字符串- 参数:
xmlInput- String- 返回:
- 根结点对象
- 抛出:
Exception- Exception
-
parseInputXMLDoc
将XML格式的字符串转化为Document对象- 参数:
xmlInput- String- 返回:
- Document
- 抛出:
Exception- Exception
-
parseXMLFileToEle
加载、解析XML文件- 参数:
path- xml文件路径- 返回:
- 根结点对象
- 抛出:
Exception- Exception
-
parseXMLFileToEle
将XML文件输入流转化为文档结点对象- 参数:
is- InputStream- 返回:
- Element
- 抛出:
Exception- Exception
-
parseXMLFileToDoc
加载、解析XML文件- 参数:
path- xml文件路径- 返回:
- Document对象
- 抛出:
Exception- Exception
-
parseXMLFileToDocIgoreDTD
加载、解析XML文件- 参数:
path- xml文件路径- 返回:
- Document对象
- 抛出:
Exception- Exception
-
parseXMLFileToDoc
加载、解析XML文件,并查找本地的DTD进行效验- 参数:
path- xml文件路径dtdName- xml本地效验文件- 返回:
- Document对象
- 抛出:
Exception- Exception
-
findDtdFile
从本地文件中查找- 参数:
dtdFileName- String- 返回:
- InputStream
- 抛出:
Exception- Exception
-
findDtdByResource
从资源JAR包中查找- 参数:
dtdFileName- String- 返回:
- InputStream
- 抛出:
Exception- Exception
-
parseXMLFileToDoc
将XML文件输入流转化为一个文档对象- 参数:
is- InputStream- 返回:
- Document
- 抛出:
Exception- Exception
-
hasChildren
public static boolean hasChildren(org.jdom2.Element e) 是否有子结点- 参数:
e- 结点对象- 返回:
- true 有孩子结点 false 没有
-
getAllProperty
获取指定结点的属性- 参数:
e- 结点对象- 返回:
- 属性值
-
getAttribute
获取指定结点的属性 ,没有找到该对象时返回空字符串- 参数:
e- 结点对象attributeName- 属性的名称- 返回:
- 属性值
-
getChildrenByName
获取指定结点的指定名称的子结点- 参数:
e- 结点对象childName- String- 返回:
- List
-
getChildByName
-
getAllChildren
获取指定结点下的所有子结点- 参数:
e- 结点对象- 返回:
- List
-
getNodeByPathElement
根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点- 参数:
root- 根结点对象path- 形如:template-list>>table>>datastore- 返回:
- Element
-
getNodeByPathAttr
根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点- 参数:
root- 根结点对象path- 形如:template-list>>table>>datastoreattrName- String- 返回:
- String
-
getNodeByPathText
根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点- 参数:
root- 根结点对象path- 形如:template-list>>table>>datastore- 返回:
- String
-
getNodeByPath
根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点- 参数:
root- 根结点对象path- 形如:template-list>>table>>datastore- 返回:
- List
-
getText
获取结点描述- 参数:
e- 结点对象- 返回:
- String
-
getChildText
获取某一子结点的文本描述- 参数:
e-name-- 返回:
-
toString
输出XML格式字符串- 参数:
doc- Documentcharset- String- 返回:
- String
-
toString
-
toString
-
parseXml
解析成XML字符串- 参数:
obj- XML对象- 返回:
- String
-