noob help w XML input!

noob help w XML input!

hrfrankhrfrank Posts: 4Questions: 0Answers: 0
edited April 2011 in General
I am new to jQuery and am looking for simple demo code to read in XML using the data table plug-in. I can't seem to find an exact example to match what I am needing.

Here is some XML to chew on. Thanks for anyone who can lend a noob a hand...

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <!-- Edited by XMLSpy®
-->
-
-
Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985

-
Bridge of Spies
T'Pau
UK
Siren
7.90
1987

-
Private Dancer
Tina Turner
UK
Capitol
8.90
1983

-
Midt om natten
Kim Larsen
EU
Medley
7.80
1983

-
Pavarotti Gala Concert
Luciano Pavarotti
UK
DECCA
9.90
1991

-
The dock of the bay
Otis Redding
USA
Atlantic
7.90
1987

-
Picture book
Simply Red
EU
Elektra
7.20
1985

-
Red
The Communards
UK
London
7.80
1987

-
Unchain my heart
Joe Cocker
USA
EMI
8.20
1987

Replies

  • hrfrankhrfrank Posts: 4Questions: 0Answers: 0
    Here is the code I am using. Please make suggestions as to why I cannot see the data tables.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




    Reading XML with jQuery


    #page-wrap
    {
    border:solid 1px #FF66FF;
    margin: 10px 5px 10px 0;
    padding: 5px 10px;
    width: 500px;
    }

    @import "demo_page.css";
    @import "demo_table.css";







    $(document).ready(function(){
    $.ajax({
    type: "GET",
    url: "cd_catalog.xml",
    dataType: "xml",
    success: function(xml) {
    var html = 'ArtistSong';
    $(xml).find('CD').each(function(){
    var cd = $(this).attr('CD');
    var artist = $(this).find('ARTIST').text();
    var title = $(this).find('TITLE').text();
    html += ''+artist+''+title+'';
    });
    html+='';
    $('#page-wrap').append($(html));
    }
    });
    $('#tableid').dataTable( {
    "sPaginationType": "full_numbers"
    } );
    });





    Reading XML with jQuery
  • cwhocwho Posts: 1Questions: 0Answers: 0
    i'm trying to do the same thing. my xml file gets read, but it says "no data available in table". any help is appreciated!
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    DataTables doesn't consume XML by default, but rather it uses JSON. What you can do is use fnServerData ( http://datatables.net/usage/callbacks#fnServerData ) to transform the XML to a 2D array using standard Javascript methods.

    Allan
This discussion has been closed.