欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery xml字符串的解析、讀取及查找方法

 更新時(shí)間:2016年03月01日 09:04:32   作者:yenange  
這篇文章主要介紹了jQuery xml字符串的解析、讀取及查找方法,涉及jQuery方法針對(duì)xml字符串的解析、讀取及遍歷查詢等操作相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery xml字符串的解析、讀取及查找方法。分享給大家供大家參考,具體如下:

xml字符串的解析

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(function () {
    var xml = '<markers>';
    xml += '<marker carId="1" carName="SHANGHAI" gpsTime="2011-08-26 21:21:11.0" lat="31.230393" lng="121.473704" direction="222" speed="22" />';
    xml += '<marker carId="7" carName="XIAMEN" gpsTime="2011-08-26 21:21:11.0" lat="24.479836" lng="118.089421" direction="222" speed="22" />';
    xml += '</markers>';
    var xmlDoc = $.parseXML(xml);
    var result="";
    $(xmlDoc).find("markers marker").each(function () {
      result += "carId = " + $(this).attr("carId")
        + " ;carName =" + $(this).attr("carName")
        + " ;gpsTime =" + $(this).attr("gpsTime") + "\n";
    });
    alert(result);
  });
</script>
</head>
<body>
</body>
</html>

請(qǐng)求

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>無(wú)標(biāo)題頁(yè)</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function search() {
  var searchStrLow = $("#txtTitle").val().toLowerCase();
  $.post("1.xml", function(data) {
    var html = "";
    $(data).find('book').each(function() {
      var titleLow = $(this).find("title").text().toLowerCase();
      if (titleLow.indexOf(searchStrLow)!=-1) {
        html += "<tr><td>" + $(this).find("title").text() + "</td>";
        html += "<td>" + $(this).find("author").text() + "</td>";
        html += "<td>" + $(this).find("year").text() + "</td></tr>";
        $("#tbody1").html(html);
      }
    });
  });
}
</script>
</head>
<body>
  <span>輸入標(biāo)題:</span><input id="txtTitle" type="text" />
  <input id="Button1" type="button" value="搜索" onclick="search()" />
  <table style="width: 100%;">
    <thead><tr><td>Title</td><td>Author</td><td>Year</td></tr></thead>
    <tbody id="tbody1">
    </tbody>
  </table>
</body>
</html>

xml:

<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
  <book id="No1">
    <title>An Introduction to XML</title>
    <author>Chunbin</author>
    <year>2010</year>
    <price>98.0</price>
  </book>
  <book id="No2">
    <title>The Performance of DataBase</title>
    <author>John</author>
    <year>1996</year>
    <price>56.0</price>
  </book>
</bookstore>

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery操作xml技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見(jiàn)經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》、《jquery選擇器用法總結(jié)》及《jQuery常用插件及用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • jQuery刪除一個(gè)元素后淡出效果展示刪除過(guò)程的方法

    jQuery刪除一個(gè)元素后淡出效果展示刪除過(guò)程的方法

    這篇文章主要介紹了jQuery刪除一個(gè)元素后淡出效果展示刪除過(guò)程的方法,實(shí)例分析了jQuery中fadeTo及slideUp等方法的使用技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-03-03
  • jQuery實(shí)現(xiàn)選中行變色效果(實(shí)例講解)

    jQuery實(shí)現(xiàn)選中行變色效果(實(shí)例講解)

    下面小編就為大家?guī)?lái)一篇jQuery實(shí)現(xiàn)選中行變色效果(實(shí)例講解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-07-07
  • JQuery之focus函數(shù)使用介紹

    JQuery之focus函數(shù)使用介紹

    focus函數(shù)可以用來(lái)發(fā)生點(diǎn)擊某個(gè)按鈕或者提交值錯(cuò)誤等觸發(fā)事件發(fā)生時(shí)把焦點(diǎn)給到某個(gè)元素,具體用法如下,感興趣的朋友可以參考下
    2013-08-08
  • jquery ajax分頁(yè)插件的簡(jiǎn)單實(shí)現(xiàn)

    jquery ajax分頁(yè)插件的簡(jiǎn)單實(shí)現(xiàn)

    這篇文章主要介紹了jquery ajax分頁(yè)插件的簡(jiǎn)單實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下
    2016-01-01
  • Jquery Select操作方法集合腳本之家特別版

    Jquery Select操作方法集合腳本之家特別版

    很多朋友對(duì)jquery select的操作很有興趣,但網(wǎng)上的東西太多,所以腳本之家特別將Jquery Select操作方法整理下,方便大家查找。
    2010-05-05
  • jQuery學(xué)習(xí)筆記之回調(diào)函數(shù)

    jQuery學(xué)習(xí)筆記之回調(diào)函數(shù)

    回調(diào)函數(shù)就是一個(gè)通過(guò)函數(shù)指針調(diào)用的函數(shù).這篇文章主要介紹了jQuery學(xué)習(xí)筆記之回調(diào)函數(shù)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-08-08
  • JQuery實(shí)現(xiàn)展開(kāi)關(guān)閉層的方法

    JQuery實(shí)現(xiàn)展開(kāi)關(guān)閉層的方法

    這篇文章主要介紹了JQuery實(shí)現(xiàn)展開(kāi)關(guān)閉層的方法,實(shí)例分析了jQuery的slideToggle方法使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-02-02
  • jquery表單驗(yàn)證需要做些什么

    jquery表單驗(yàn)證需要做些什么

    jquery表單驗(yàn)證需要做些什么,大家知道嗎?其實(shí)很簡(jiǎn)單只要做四件事情就可以順利完成表單驗(yàn)證,想知道哪四件事情嗎,請(qǐng)仔細(xì)閱讀下文。
    2015-11-11
  • Jquery實(shí)現(xiàn)的一種常用高亮效果示例代碼

    Jquery實(shí)現(xiàn)的一種常用高亮效果示例代碼

    本篇文章只要是對(duì)Jquery實(shí)現(xiàn)的一種常用高亮效果示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
    2014-01-01
  • jQuery AjaxQueue改進(jìn)步驟

    jQuery AjaxQueue改進(jìn)步驟

    之前用jquery實(shí)現(xiàn)了一個(gè)簡(jiǎn)單的AjaxQueue,用于管理ajax請(qǐng)求的發(fā)送順序。這次改進(jìn)了下。
    2011-10-10

最新評(píng)論