How to parse XML string value using jQuery ?

Posted by Vijay on Stack Overflow See other posts from Stack Overflow or by Vijay
Published on 2010-06-09T06:57:21Z Indexed on 2010/06/09 7:02 UTC
Read the original article Hit count: 170

Filed under:
|
|

Hi All,
I am new to jquery. I am trying to parse xml string using jquery. I have found one sample code;

 $(function() {

        $.get('data.xml', function(d) 
        {

            var data = "";
            var startTag = "<table border='1' id='mainTable'><tbody><tr><td style=\"width: 120px\">Name</td><td style=\"width: 120px\">Link</td></tr>";
            var endTag = "</tbody></table>";
            $(d).find('url').each(function() {
            var $url = $(this);
            var link = $url.find('link').text();
            var name = $url.find('name').text();
            data += '<tr><td>' + name + '</td>';
            data += '<td>' + link + '</td></tr>';
        })
          $("#content").html(startTag + data + endTag);
        ;
        });

        });


In this case, I am able to parse and fetch the values from xml file.
but now what I am looking for is instead of reading file from desk, I want to read the xml from string. Say, instead of data.xml I want to parse string which consists of well formed xml.
does anyone have any idea about this ?
Thanks in advance

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery