XML > jQuery reading

前端 未结 2 1561
挽巷
挽巷 2020-12-20 08:16

How can i read this XML File with jQuery? With \"normal tags\" its no problem like:Mustang

HTML/jQuery:

相关标签:
2条回答
  • 2020-12-20 08:49

    You can select elements by attribute, you just have to use an attributes selector, or a filter() function etc.

    $(document).ready(function () {
        $.get("AMA.xml", function (XMLArray) {
            var xml = $.parseXML(XMLArray);
            $(xml).find("dataset").each(function () {
                var number = $('[key="article.plunumber"]', this).text();
                var name = $('[key="article.name"]', this).text();
                var price = $('[key="article.price"]', this).text();
                $("#AMAContainer").append("<p>" + number + "<br>" + name + "<br>" + price + "</p>");
            });
        });
    });
    
    0 讨论(0)
  • 2020-12-20 09:06
    var number = $myAMA.find('var[key="article.plunumber"]');
    

    Treat the <var> just like you're treating the <dataset>

    0 讨论(0)
提交回复
热议问题