new XmlUtil()
XML文件操作工具类
方法列表
| 名称 | 说明 |
|---|---|
| .getChildNode(node, childElementName) | 获取子节点 |
| .getChildNodeValue(node, childElementName) | 获取子节点的值 |
| .getNodeValue(node) | 获取Xml节点的值 |
| .getString(node) | 将XmlNode节点转换为字符串 |
| .load(url, args) | 加载XML文件(可支持IE7+和FF等) |
| .loadXML(str) | 加载XML字符串,可支持IE7+和FF等,IE9使用该方法返回的Document对象不支持Xpath |
| .selectNodes(node, xpath, nsr) | 使用XPath搜索节点集 |
| .selectSingleNode(node, xpath, nsr) | 使用XPath搜索节点 |
| .transform(xmlSource, xslFileName) | 使用XSLT转换XML文档 |
详细说明
(static) getChildNode(node, childElementName)
获取子节点
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
node |
XmlNode | ||
childElementName |
String |
返回值
XmlNode
(static) getChildNodeValue(node, childElementName)
获取子节点的值
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
node |
XmlNode | ||
childElementName |
String |
返回值
String nodeValue
(static) getNodeValue(node)
获取Xml节点的值
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
node |
XmlElement |
返回值
String
(static) getString(node)
将XmlNode节点转换为字符串
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
node |
XmlNode |
返回值
String
(static) load(url, args)
加载XML文件(可支持IE7+和FF等)
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
url |
String | ||
args |
Object | {async, success} |
(static) loadXML(str)
加载XML字符串,可支持IE7+和FF等,IE9使用该方法返回的Document对象不支持Xpath
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
str |
String |
返回值
Document
(static) selectNodes(node, xpath, nsr)
使用XPath搜索节点集
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
node |
XmlNode | ||
xpath |
String | ||
nsr |
String |
返回值
Array 节点集
(static) selectSingleNode(node, xpath, nsr)
使用XPath搜索节点
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
node |
XmlNode | ||
xpath |
String | ||
nsr |
String |
返回值
XmlNode 节点
(static) transform(xmlSource, xslFileName)
使用XSLT转换XML文档
参数
| 名称 | 类型 | 缺省值 | 说明 |
|---|---|---|---|
xmlSource |
Document | ||
xslFileName |
String |
返回值
Document
搜索