Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

jQuery - Read a XML file

Viewed:  1688 
Posted On:  25/10/2014 02:19:03 
How we can read a xml file in c# using jQuery ? 

In this article I am going to explain how we can read a xml file using jQuery in c#.

Below is my xml file:


Image 1.

Below is my jQuery and aspx code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Read a XML using jQuery</title>
        .html, body
            font-family: Verdana;
            font-size: 12px;
            background: Skyblue;
        #dvContent label
            padding: 2px 10px;
            text-align: left;
            width: 120px;
            display: block;
            float: left;
            border: 1px solid Red;
    <script type="text/javascript" src=""></script>
    <script type="text/javascript"> 
        $(document).ready(function() {
            $('#dvContent').append("<p><label><strong>Employee ID</strong></label><label><strong>Name</strong></label><label><strong>Joining
                                                 Date</strong></label><label><strong>Company Name</strong></label>

                type: "GET",
                url: "EmployeeData.xml",
                dataType: "xml",
                success: function(xml) {
                    $(xml).find('Employees').each(function() {
                        $('#dvContent').append("<p><label>" +
                    $(this).find('EmployeeID').text() + "</label><label>" +
                    $(this).find('Name').text() + "</label><label>" +
                    $(this).find('JoiningDate').text() + "</label><label>" +
                    $(this).find('CompanyName').text() + "</label><label>" +
                    $(this).find('Address').text() + "</label></p><br/>");
                error: function() {
                    alert("Error occurred in Reading XML.");

    <form id="form1" runat="server">
        <span style="font-size: 16pt; text-align: center; width: 100%">Read XML using jQuery</span></div>
    <div id="dvContent">

Now Run the application:


Image 2.

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us