解决方案 »

  1.   

    在顶一下 jquery 解析xml问题
      

  2.   

    一个遍历显示而已。网上写法很多。http://www.nowamagic.net/jquery/jquery_ParsingXmlData.php
      

  3.   

    jquery 有个插件叫 jquery.xml2json.js
      

  4.   


    $(function(){
      var xmlStr = '<?xml version="1.0" encoding="utf-8"?>\
                  <info>\
                    <List>\
                      <book index="1">\
                        <author index="1">\
                          <name>张1三</name>\
                          <title>标题1</title>\
                        </author>\
                      </book>\
                      <book index="2">\
                        <author index="2">\
                          <name>张三2</name>\
                          <title>标题2</title>\
                        </author>\
                      </book>\
                      <book index="3">\
                        <author index="3">\
                          <name>张三3</name>\
                          <title>标题3</title>\
                        </author>\
                      </book>\
                    </List>\
                  </info>';
      var xml = $(xmlStr);    
      xml.find('List book').each(function(){
          var _this = $(this);
          var authorIndex = _this.find('author').attr('index')
          var name = _this.find('name').text();
          var title = _this.find('title').text();
          console.log( authorIndex + '\t' + name + '\t' + title);
      });
    });