Tom Powers
asked on
reading xml stop at first value
I have a xml sheet and I wrote bsome code and it runs and retrieve's the last xml player's values I know this exists but not sure how to code it to stop on the first xml player node. The one that is outside the two teams I think the code I wrote justs flies right over the whole xml doc.
THIS IS WHAT i'M AFTER Michael Carter-Williams < Player ID="2411" TeamID="106" Firstname="Michael" Lastname="Carter-Williams" Number="1" Position="G" FGAtt="0" FGMade="0" TresMade="0" TresAtt="0" FTMade="0" FTAtt="0" ORebounds="0" DRebounds="0" Assists="1" PerFouls="0" Steals="0" Turnovers="0" BlockedShots="0" Points="0" TechnicalFouls="0"/>
Court.html
18672.XML
function loadData() {
$.ajax({
type: "GET",
url: xmlPath + "/" + xmlGameID + ".xml",
dataType: "xml",
success: function (data) {
var d = $(data);
var Play = d.find('Play');
// d.find('Team').each(function (i, Team) {
var msg;
var inn = Play.attr('TimeLeft');
var playtype1 = Play.attr('PlayType');
msg = Play.find('narrative').attr('text');
$('#txtGametext').html(msg);
$('#time').html(inn);
$('#playtype').html(playtype1);
var players = $(data).find("Player");
$.each(players,function(i,player) {
player=$(player);
var tid = player.attr('TeamID');
var pid = player.attr('ID');
$('#imgcenter').attr('src', 'http://dev.sportsnetwork.com/aspdata/nhl2/NBA/Images/NBAlOGOSZ/'+ tid +".png");
var txt;
$('#imgplayer').attr("src","http://images.sportsnetwork.com/bask/nba/atthecourt/players/" + pid + ".jpg");
txt = " " +
player.attr("FirstName") + " " +
player.attr("Lastname") + ", " +
player.attr("Pos");
// getStats(player,txt,img,li);
$('#txtpts').html(player.attr("Points"));
// $("#players").append(li);
$('txtassists').html(player.attr("Assists"));
});
// });
}
});
}
</script>
Please show me what I did wrong and correct syntax. Thanks EETHIS IS WHAT i'M AFTER Michael Carter-Williams < Player ID="2411" TeamID="106" Firstname="Michael" Lastname="Carter-Williams"
Court.html
18672.XML
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER