类 UXml
java.lang.Object
com.gdxsoft.easyweb.utils.UXml
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static boolean增加节点static DocumentappendNode(Document sourceDocument, String nodeXmlString, String tagPath) 在Xml文档中增加新的节点static DocumentasDocument(String xmlSource) 从xml字符串中返回XmlDocument对象static Node将xml字符串转换为 nodestatic String返回Xml字符,不包含 <?static String返回 Xml字符串 ,包含 <?static StringasXmlPretty(Node node) 美化Xml输出static Document创建并返回空白的xml文档static DocumentcreateBlankDocument(String dtd, String qName) 生成空文件static DocumentcreateSavedDocument(String path, String rootTagName) 生成空xml文档,并保存为文件static StringcreateXmlValue(String s1) 生成可Xml节点值static StringfilterInvalidXMLcharacter(String xmlStr) 过滤非法的字符 0x00 - 0x08 ,0x0b - 0x0c ,0x0e - 0x1fstatic ElementfindNode(Element fromNode, String findTag, String findAttr, String checkValue, boolean isIgnoreCase) 从Xml中查找某个节点static DocumentBuilderFactory获取安全的 DocumentBuilderFactory,避免 XXE 攻击getElementAttributes(Element item, boolean keyToLower) Get XML Element all attributesstatic Node获取配置文件的节点static Node获取配置文件的节点static Node获取配置文件的节点static booleanremoveNode(Document document, String tagPath, String nodeAttribute, String attValue) 删除节点static DocumentretDocument(String xmlPath) 读取文件,返回 Documentstatic DocumentretDocument(String xmlPath, boolean isAbsolutePath) 读取文件,返回 Documentstatic Node返回下级节点static Node返回下级节点static Node返回下级节点static NodeListretNodeList(Document document, String tagName) 返回下级节点集合static NodeListretNodeList(Element element, String tagName) 返回下级节点集合static NodeListretNodeList(Node node, String tagName) 返回下级节点集合static NodeListretNodeListByPath(Document document, String tagPath) 返回节点列表通过路径static NodeListretNodeListByPath(Element element, String tagPath) 返回节点列表通过路径static NodeListretNodeListByPath(Node node, String tagPath) 返回节点列表通过路径static StringretNodeText(Node node) 返回节点textstatic StringretNodeValue(Node node, String attName) 返回属性值static booleansaveDocument(Document document) 将 Document对象保存为文件static booleansaveDocument(Document document, String xmlFileName) save xml document to filestatic String将XML文件转换为JSON字符串static String将XML文件转换为JSON字符串,支持格式化输出static String将XML字符串转换为JSON字符串static String将XML文件路径转换为JSON字符串static String将XML文件路径转换为JSON字符串,支持格式化输出static String将XML字符串转换为JSON字符串,支持格式化输出
-
构造器详细资料
-
UXml
public UXml()
-
-
方法详细资料
-
getElementAttributes
-
filterInvalidXMLcharacter
-
findNode
-
createXmlValue
-
retDocument
public static Document retDocument(String xmlPath, boolean isAbsolutePath) throws ParserConfigurationException, SAXException, IOException 读取文件,返回 Document- 参数:
xmlPath- xml文件路径isAbsolutePath- 是否为绝对路径- 返回:
- document 对象
- 抛出:
ParserConfigurationExceptionSAXExceptionIOException
-
retDocument
public static Document retDocument(String xmlPath) throws ParserConfigurationException, SAXException, IOException 读取文件,返回 Document- 参数:
xmlPath- xml文件路径- 返回:
- document 对象
- 抛出:
ParserConfigurationExceptionSAXExceptionIOException
-
saveDocument
-
saveDocument
将 Document对象保存为文件- 参数:
document- Document对象- 返回:
- 是否保存成功
-
retNodeValue
-
retNodeText
-
retNodeList
-
retNodeList
-
retNodeList
-
retNode
-
retNode
-
retNode
-
retNodeListByPath
-
retNodeListByPath
-
retNodeListByPath
-
addNode
-
removeNode
-
queryNode
public static Node queryNode(String xmlName, String itemName, String tagPath) throws ParserConfigurationException, SAXException, IOException 获取配置文件的节点- 参数:
xmlName- 文件路径itemName- 节点名称tagPath- 路径- 返回:
- 节点
- 抛出:
IOExceptionSAXExceptionParserConfigurationException
-
queryNode
-
queryNode
-
asXml
-
asXmlPretty
-
asXmlAll
-
asNode
-
getDocumentBuilder
获取安全的 DocumentBuilderFactory,避免 XXE 攻击- 返回:
- DocumentBuilderFactory
-
asDocument
-
createBlankDocument
-
createSavedDocument
-
createBlankDocument
-
appendNode
-
xml2Json
-
xml2Json
-
xml2Json
将XML文件转换为JSON字符串- 参数:
xmlFile- XML文件- 返回:
- JSON字符串
- 抛出:
IOException- 文件读取异常
-
xml2Json
将XML文件转换为JSON字符串,支持格式化输出- 参数:
xmlFile- XML文件indentFactor- 缩进因子,用于格式化输出- 返回:
- JSON字符串
- 抛出:
IOException- 文件读取异常
-
xml2Json
将XML文件路径转换为JSON字符串- 参数:
xmlPath- XML文件路径isAbsolutePath- 是否为绝对路径- 返回:
- JSON字符串
- 抛出:
IOException- 文件读取异常
-
xml2Json
public static String xml2Json(String xmlPath, boolean isAbsolutePath, int indentFactor) throws IOException 将XML文件路径转换为JSON字符串,支持格式化输出- 参数:
xmlPath- XML文件路径isAbsolutePath- 是否为绝对路径indentFactor- 缩进因子,用于格式化输出- 返回:
- JSON字符串
- 抛出:
IOException- 文件读取异常
-