本文实例讲述了jQuery实现的解析本地 XML 文档操作。分享给大家供大家参考,具体如下:
Create a jQuery object using an XML string and obtain the value of the title node.
jQuery.parseXML demo
方法二:
function parseXML(xmlFileAddr) {
$.ajax({
type: "GET",
url: xmlFileAddr,
dataType: "xml",
success: function(data, textStatus, jqXHR){//读取成功
console.log(data)
// todo......
},
error: function(jqXHR, textStatus, errorThrown) {//读取失败时
$.alert('解析文件失败!')
}
});
}
使用方法:
PS:这里再为大家提供几款关于xml操作相关在线工具供大家参考使用:
在线XML/JSON互相转换工具:
http://tools.jb51.net/code/xmljson
在线格式化XML/在线压缩XML:
http://tools.jb51.net/code/xmlformat
XML在线压缩/格式化工具:
http://tools.jb51.net/code/xml_format_compress
xml代码在线格式化美化工具:
http://tools.jb51.net/code/xmlcodeformat
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery操作xml技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。



