类 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 file
-
构造器详细资料
-
UXml
public UXml()
-
-
方法详细资料
-
getElementAttributes
Get XML Element all attributes- 参数:
item- The elementkeyToLower- nodeName to lower case- 返回:
- Map <nodeName, nodeValue>
-
filterInvalidXMLcharacter
过滤非法的字符 0x00 - 0x08 ,0x0b - 0x0c ,0x0e - 0x1f- 参数:
xmlStr-- 返回:
- 过滤后的xml
-
findNode
public static Element findNode(Element fromNode, String findTag, String findAttr, String checkValue, boolean isIgnoreCase) 从Xml中查找某个节点- 参数:
fromNode-findTag- 要查找的TagNamefindAttr- 检查的属性名称checkValue- 检测值isIgnoreCase- 是否大小写匹配- 返回:
- 节点
-
createXmlValue
生成可Xml节点值- 参数:
s1-- 返回:
- 节点值
-
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
save xml document to file- 参数:
document- Document对象xmlFileName- 文件名- 返回:
- 是否保存成功
-
saveDocument
将 Document对象保存为文件- 参数:
document- Document对象- 返回:
- 是否保存成功
-
retNodeValue
返回属性值- 参数:
node- 当前节点attName- 属性值- 返回:
- 属性值
-
retNodeText
返回节点text- 参数:
node- 当前节点- 返回:
- TextContent
-
retNodeList
返回下级节点集合- 参数:
document- document对象tagName- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 集合
-
retNodeList
返回下级节点集合- 参数:
node- node 对象tagName- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 集合
-
retNodeList
返回下级节点集合- 参数:
element- element 对象tagName- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 集合
-
retNode
返回下级节点- 参数:
node- node对象tagName- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 下级节点
-
retNode
返回下级节点- 参数:
document-tagName- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 下级节点
-
retNode
返回下级节点- 参数:
element-tagName- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 下级节点
-
retNodeListByPath
返回节点列表通过路径- 参数:
element- element 元素tagPath- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 列表
-
retNodeListByPath
返回节点列表通过路径- 参数:
document- document对象tagPath- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 列表
-
retNodeListByPath
返回节点列表通过路径- 参数:
node- 父节点tagPath- 下级节点表达式,例如 aa/bb/cc,返回 aa<bb<cc- 返回:
- 节点列表
-
addNode
增加节点- 参数:
document-newChilid-tagPathParent-- 返回:
- 是否成功
-
removeNode
public static boolean removeNode(Document document, String tagPath, String nodeAttribute, String attValue) 删除节点- 参数:
document-tagPath-nodeAttribute-attValue-- 返回:
- 是否成功
-
queryNode
public static Node queryNode(String xmlName, String itemName, String tagPath) throws ParserConfigurationException, SAXException, IOException 获取配置文件的节点- 参数:
xmlName- 文件路径itemName- 节点名称tagPath- 路径- 返回:
- 节点
- 抛出:
IOExceptionSAXExceptionParserConfigurationException
-
queryNode
获取配置文件的节点- 参数:
document- xml文档itemName- 节点名称tagPath- 路径- 返回:
- 节点
-
queryNode
public static Node queryNode(Document document, String attributeName, String itemName, String tagPath) 获取配置文件的节点- 参数:
document- xml文档attributeName- 属性名itemName- 节点名称tagPath- 路径- 返回:
- 节点
-
asXml
返回Xml字符,不包含 <?xml version="1.0" encoding="UTF-8"?>- 参数:
node- 节点- 返回:
- Xml字符串
-
asXmlPretty
美化Xml输出- 参数:
node- 节点- 返回:
- Xml字符串
-
asXmlAll
返回 Xml字符串 ,包含 <?xml version="1.0" encoding="UTF-8"?>- 参数:
node-- 返回:
- Xml字符串
-
asNode
将xml字符串转换为 node- 参数:
xmlSource-- 返回:
- node
-
getDocumentBuilder
获取安全的 DocumentBuilderFactory,避免XXE攻击- 返回:
- DocumentBuilderFactory
-
asDocument
从xml字符串中返回XmlDocument对象- 参数:
xmlSource- xml字符串- 返回:
- Document
-
createBlankDocument
创建并返回空白的xml文档- 返回:
- Document
-
createSavedDocument
生成空xml文档,并保存为文件- 参数:
path- xml路径- 返回:
- xml文档
-
createBlankDocument
生成空文件- 参数:
dtd- dtd文件qName- qName- 返回:
- Document
-
appendNode
在Xml文档中增加新的节点- 参数:
sourceDocument- 源文档nodeXmlString- node的Xml字符tagPath- 增加的路径- 返回:
- 新文档
-