类 XmlUtil

java.lang.Object
com.sh.common.util.XmlUtil

public class XmlUtil extends Object

Title: 解析XML文件类

Copyright: Copyright JXC(c) 2009-2010

Company:首亨软件(重庆)有限公司

  • 字段详细资料

    • log4j

      protected static org.apache.logging.log4j.Logger log4j
  • 方法详细资料

    • parseInputXMLString

      public static org.jdom2.Element parseInputXMLString(String xmlInput)
      加载、解析XML格式的字符串
      参数:
      xmlInput - String
      返回:
      根结点对象
      抛出:
      Exception - Exception
    • parseInputXMLDoc

      public static org.jdom2.Document parseInputXMLDoc(String xmlInput) throws Exception
      将XML格式的字符串转化为Document对象
      参数:
      xmlInput - String
      返回:
      Document
      抛出:
      Exception - Exception
    • parseXMLFileToEle

      public static org.jdom2.Element parseXMLFileToEle(String path) throws Exception
      加载、解析XML文件
      参数:
      path - xml文件路径
      返回:
      根结点对象
      抛出:
      Exception - Exception
    • parseXMLFileToEle

      public static org.jdom2.Element parseXMLFileToEle(InputStream is) throws Exception
      将XML文件输入流转化为文档结点对象
      参数:
      is - InputStream
      返回:
      Element
      抛出:
      Exception - Exception
    • parseXMLFileToDoc

      public static org.jdom2.Document parseXMLFileToDoc(String path) throws Exception
      加载、解析XML文件
      参数:
      path - xml文件路径
      返回:
      Document对象
      抛出:
      Exception - Exception
    • parseXMLFileToDocIgoreDTD

      public static org.jdom2.Document parseXMLFileToDocIgoreDTD(String path) throws Exception
      加载、解析XML文件
      参数:
      path - xml文件路径
      返回:
      Document对象
      抛出:
      Exception - Exception
    • parseXMLFileToDoc

      public static org.jdom2.Document parseXMLFileToDoc(String path, String dtdName) throws Exception
      加载、解析XML文件,并查找本地的DTD进行效验
      参数:
      path - xml文件路径
      dtdName - xml本地效验文件
      返回:
      Document对象
      抛出:
      Exception - Exception
    • findDtdFile

      public static InputStream findDtdFile(String dtdFileName) throws Exception
      从本地文件中查找
      参数:
      dtdFileName - String
      返回:
      InputStream
      抛出:
      Exception - Exception
    • findDtdByResource

      public static InputStream findDtdByResource(String dtdFileName) throws Exception
      从资源JAR包中查找
      参数:
      dtdFileName - String
      返回:
      InputStream
      抛出:
      Exception - Exception
    • parseXMLFileToDoc

      public static org.jdom2.Document parseXMLFileToDoc(InputStream is) throws Exception
      将XML文件输入流转化为一个文档对象
      参数:
      is - InputStream
      返回:
      Document
      抛出:
      Exception - Exception
    • hasChildren

      public static boolean hasChildren(org.jdom2.Element e)
      是否有子结点
      参数:
      e - 结点对象
      返回:
      true 有孩子结点 false 没有
    • getAllProperty

      public static List<String> getAllProperty(org.jdom2.Element e)
      获取指定结点的属性
      参数:
      e - 结点对象
      返回:
      属性值
    • getAttribute

      public static String getAttribute(org.jdom2.Element e, String attributeName)
      获取指定结点的属性 ,没有找到该对象时返回空字符串
      参数:
      e - 结点对象
      attributeName - 属性的名称
      返回:
      属性值
    • getChildrenByName

      public static List<org.jdom2.Element> getChildrenByName(org.jdom2.Element e, String childName)
      获取指定结点的指定名称的子结点
      参数:
      e - 结点对象
      childName - String
      返回:
      List
    • getChildByName

      public static org.jdom2.Element getChildByName(org.jdom2.Element e, String childName)
    • getAllChildren

      public static List<org.jdom2.Element> getAllChildren(org.jdom2.Element e)
      获取指定结点下的所有子结点
      参数:
      e - 结点对象
      返回:
      List
    • getNodeByPathElement

      public static org.jdom2.Element getNodeByPathElement(org.jdom2.Element root, String path)
      根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点
      参数:
      root - 根结点对象
      path - 形如:template-list>>table>>datastore
      返回:
      Element
    • getNodeByPathAttr

      public static String getNodeByPathAttr(org.jdom2.Element root, String path, String attrName)
      根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点
      参数:
      root - 根结点对象
      path - 形如:template-list>>table>>datastore
      attrName - String
      返回:
      String
    • getNodeByPathText

      public static String getNodeByPathText(org.jdom2.Element root, String path)
      根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点
      参数:
      root - 根结点对象
      path - 形如:template-list>>table>>datastore
      返回:
      String
    • getNodeByPath

      public static List<org.jdom2.Element> getNodeByPath(org.jdom2.Element root, String path)
      根据指定路径查找结点对像,此方法适应于除最后一个结点外,其余的都为单结点,即没有相同的兄弟结点
      参数:
      root - 根结点对象
      path - 形如:template-list>>table>>datastore
      返回:
      List
    • getText

      public static String getText(org.jdom2.Element e)
      获取结点描述
      参数:
      e - 结点对象
      返回:
      String
    • getChildText

      public static String getChildText(org.jdom2.Element e, String name)
      获取某一子结点的文本描述
      参数:
      e -
      name -
      返回:
    • toString

      public static String toString(org.jdom2.Document doc, String charset)
      输出XML格式字符串
      参数:
      doc - Document
      charset - String
      返回:
      String
    • toString

      public static String toString(org.jdom2.Element el)
    • toString

      public static String toString(List<org.jdom2.Element> elList)
    • parseXml

      public static String parseXml(Object obj)
      解析成XML字符串
      参数:
      obj - XML对象
      返回:
      String