How To Read xml using JQuery

How To Read xml using JQuery

In this post, I will show how to read XML using JQuery

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">

   <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>

   <script type="text/javascript">

       $(document).ready(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);


   <div id="content">


<?xml version="1.0" encoding="utf-8" ?>

Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads