本文实例讲述了jQuery实现的解析本地 XML 文档操作。分享给大家供大家参考,具体如下:
Create a jQuery object using an XML string and obtain the value of the title node.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery.parseXML demo</title> <script src="/UploadFiles/2021-04-02/jquery-1.10.2.js">方法二:
/** * @param {String} xmlFileAddr 文件地址 */ 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('解析文件失败!') } }); }使用方法:
<script> window.onload = function() { parseXML("./xx/xx.xml"); //文件地址 } </script>PS:这里再为大家提供几款关于xml操作相关在线工具供大家参考使用:
在线XML/JSON互相转换工具:
http://tools.jb51.net/code/xmljson在线格式化XML/在线压缩XML:
http://tools.jb51.net/code/xmlformatXML在线压缩/格式化工具:
http://tools.jb51.net/code/xml_format_compressxml代码在线格式化美化工具:
http://tools.jb51.net/code/xmlcodeformat更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery操作xml技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。
最新资源
- 魔兽世界wlk阿奴巴拉克怎么打 wlk阿奴巴拉克机制
- 归龙潮阿律的笛子位置在哪 阿律的笛子图文位置一
- 归龙潮中浦城区福鼠位置在哪 中浦城区福鼠收集位
- NewViennaOctetViennaWindSoloists-TheDeccaRec
- MatteoPasqualini-JohannSebastianBachItalieni
- 【雨果唱片】陈百强《梦里人LPCD45》2012[WAV+C
- 《黑神话》纪录片9月20日上线!揭秘关卡为何删减
- 游戏科学估值已和育碧市值相当:后者有两万多名员
- 黑神话第81周目Boss伤害有多恐怖?起手伤害直接秒
- 群星.2009-原班情歌2CD【SONY】【WAV+CUE】