In this article, I have provided code for how we can read XML file using jQuery and then load it in an HTML table, to show XML in tabular form.

Suppose this is our sample XML file, which we would like to read

<?xml version="1.0"?>
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <description>An in-depth look at creating applications 
      with XML.</description>
      <author>Ralls, Kim</author>
      <title>Midnight Rain</title>
      <description>A former architect battles corporate zombies, 
      an evil sorceress, and her own childhood to become queen 
      of the world.</description>
      <author>Corets, Eva</author>
      <title>Maeve Ascendant</title>
      <description>After the collapse of a nanotechnology 
      society in England, the young survivors lay the 
      foundation for a new society.</description>
      <author>Corets, Eva</author>
      <title>Oberon's Legacy</title>
      <description>In post-apocalypse England, the mysterious 
      agent known only as Oberon helps to create a new life 
      for the inhabitants of London. Sequel to Maeve 
      <author>Corets, Eva</author>
      <title>The Sundered Grail</title>
      <description>The two daughters of Maeve, half-sisters, 
      battle one another for control of England. Sequel to 
      Oberon's Legacy.</description>

You can also find above XML file at the given URL:

Now, we would need to write HTML and jQuery code to parse XML and load data in HTML table as content.

<!DOCTYPE html>
    <title>Read XML Data Using jQuery Ajax and Load it in HTML table</title>
    <!--Include Bootstrap CSS-->
    <link rel="stylesheet" href="" crossorigin="anonymous">
      <!--Include jQuery-->
    <script src=""></script>


      Click button to Read XML and Show it in HTML

    <input type="button" value="Read XML" id="btn" />
    <table class="table table-condensed table-hovered table-striped">
      <tbody id="tableBody">

    $(document).ready(function() {
        //jQuery on button click Call
        $('#btn').click(function () {
            $('#tableBody').empty();       // Clear the table body.
            //ajax call to load XML and parse it
                type: 'GET',
                url: '',           // The file path.
                dataType: 'xml',    
                success: function(xml) {
                   //find all book tags, loop them and append to table body
                    $(xml).find('book').each(function() {
                        // Append new data to the tbody element.
                            '<tr>' +
                                '<td>' +
                                    $(this).find('author').text() + '</td> ' +
                                '<td>' +
                                    $(this).find('title').text() + '</td> ' +
                                '<td>' +
                                    $(this).find('genre').text() + '</td> ' +
                                    '<td>' +
                                    $(this).find('price').text() + '</td> ' +
                                    '<td>' +
                                    $(this).find('description').text() + '</td> ' +

In the above code, we are loading XML file from URL using jQuery Ajax.

Once the request is successful, we are looping the <book> tag of above XML, then extracting data from each tag inside it using .find('tagname').text(), and appending the text in table row using <tr>, <td>.

Here is the working fiddle sample.

That's it, we are done, here is the gif sample


If you want the Javascript version of the above, you can see here: Read XML using Javascript

You may also like to read:

Email validation using jQuery (Various Methods)

Creating sticky header on scroll using CSS