jquery - How to get xml data

Im a total noob to html, css, javascript, and programming altogether. Please bear with me.Im trying to populate my table using jquery. The data will be coming from an xml file.\[code\]football_player.xml\[/code\]:\[code\]<?xml version="1.0" encoding="UTF-8"?><football_player> <name>Cristiano Ronaldo</name> <club>Real Madrid</club> <number>7</number> <country>Portugal </country> <name>Fernando Torres </name> <club>Chelsea </club> <number>9</number> <country>Spain</country> <name>Iker Casillas</name> <club>Real Madrid </club> <number>1</number> <country>Spain</country> <name>David Beckham</name> <club>Los Angeles Galaxy</club> <number>23</number> <country>England</country></football_player>\[/code\]My html table:\[code\]<table> <thead> <tr> <th>Name</th> <th>Club</th> <th>Number</th> <th>Country</th> </tr> </thead> <tbody> </tbody> </tfoot> </tfoot></table>\[/code\]My javascript/jquery script:\[code\]$(document).ready(function () { $.ajax({ type: "GET", url: "football_player.xml", dataType: "xml", success: function(xml) { $(xml).find("football_player").each(function () { $("table tbody").append("<tr>"); $("table tbody").append("<td>" + $(this).find("name").text() + "</td>"); $("table tbody").append("<td>" + $(this).find("club").text() + "</td>"); $("table tbody").append("<td>" + $(this).find("number").text() + "</td>"); $("table tbody").append("<td>" + $(this).find("country").text() + "</td>"); $("table tbody").append("</tr>"); }); } });});\[/code\]I swear Im really a noob. I don't have any idea of what Im doing. Please help. I really want to learn. Thanks in advance.
 
Back
Top