简体   繁体   中英

How we can read xml file with jquery from database (postgres)?

Hi I am working on jquery and xml . I am new on this . I did some work on jquery and xml . Actually I read xml file with jquery and populate it on front end . But now I write this xml file in database . But I don't know How I read xml from database following my code represent read a xml file , please anyone help me What I can change in this code for read database xml .

$.ajax({
        url: 'file.xml',
        async: false,
        success: function(xml) {

            $(xml).find('Tab').each(function(){
                var id = $(this).attr('URL');
                var tab = $(this).attr('TabName');

                $("ul").append("<li><a href="+ id +">"+ tab +"</li>");

            });

        }
    });  

jQuery provides a parseXML() function. Try modifying your code to:

   $.ajax({
        url: 'file.xml',
        async: false,
        success: function(xml) {

            $xml = $($.parseXML(xml));

            $xml.find('Tab').each(function(){
                var id = $(this).attr('URL');
                var tab = $(this).attr('TabName');

                $("ul").append("<li><a href="+ id +">"+ tab +"</li>");

            });

        }
    }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM