XML parsing in Jquery

后端 未结 1 1794
不知归路
不知归路 2021-01-07 07:37

I have an XML file which has four tag:


  
     
  

        
相关标签:
1条回答
  • 2021-01-07 07:56

    You have a couple of options:

    var xml = $(xml);
    $('resultGroups > name', xml).each(function() {
        alert($(this).text());
    });
    

    This uses the direct descendant selector. You could also use children, which does the same thing:

    $('resultGroups', xml).children('name').each(function() {
        alert($(this).text());
    });
    
    0 讨论(0)
提交回复
热议问题