Solved

can't pull one value from xml file

Posted on 2013-11-14
2
218 Views
Last Modified: 2013-11-14
I got this xml doc that I can't pull one value Assists from it. I've tried everything maybe it's something simple I'm overlooking Or something bigger Please help.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
body {
	background-color: #000;
}
#apDiv1 {
	position: absolute;
	width: 619px;
	height: 376px;
	z-index: 10;
	left: 75px;
	top: 15px;
}
.apdivtbheader {
	color: #FFF;
}
.centermid {
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
	font-size: 16px;
	font-weight: bold;
	color: #000;
	text-align: center;
	vertical-align: middle;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var xmlPath = '.' //'/xml/nba/scores/real';
        var xmlGameID = '18673'; 
		
function loadData() {
 $.ajax({
                    type: "GET",
                    url: xmlPath + "/" + xmlGameID + ".xml",
                    dataType: "xml",
                    success: function (data) {
                        var d = $(data);
						 var Play = d.find('Play');
						  var msg;
						  var inn = Play.attr('TimeLeft');
						 var playtype1 = Play.attr('PlayType');
      msg = Play.find('narrative').attr('text');
                            $('#txtgameplay').html(msg);   
							$('#txttimeleft').html(inn);
                             $('#txtplaytype').html(playtype1);  
                        
                        //convert the XML into a jQuery object
gameData = $(data);

//Get the Players node
players = gameData.find('Players');

//Now loop through each Player in the Players node
$('Player', players).each(function(i, player) {
	//Output some of the attributes for this player
	
               // if (player.size() > 0) {
                                
                             //$.each(players,function(i,player) {
          player=$(player);
        var tid = player.attr('TeamID');
         var pid =  player.attr('ID');  
		 var pts =  player.attr('Points')
		 var assists = player.attr('Assists')
		  $('#txtpoints').html(pts);
          //  $("#players").append(li);
			$('txtassists').html(assists);
             $('#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);
           
							// }
     //   });

                    });
                    }
                });	
}
</script>
</head>

<body>
<table width="750" border="0">
  <tr>
    <td><div align="center">
      <div id="apDiv1">
        <table width="650" border="0">
          <tr class="apdivtbheader">
            <td width="121" bgcolor="#0099CC"><div align="center"></div></td>
            <td width="114" bgcolor="#0099CC"><div align="center"><strong>TimeLeft</strong></div></td>
            <td width="122" bgcolor="#0099CC"><div align="center"><strong>PlayType</strong></div></td>
            <td width="120" bgcolor="#0099CC"><div align="center"><strong>Points</strong></div></td>
            <td width="120" bgcolor="#0099CC"><div align="center"><strong>Assits</strong></div></td>
          </tr>
          <tr class="apdivtbheader">
            <td height="82" class="centermid"><p><img src="Images/misc/player.jpg" name="imgplayer" width="60" height="80" id="imgplayer"></p></td>
            <td class="centermid" id="txttimeleft"></td>
            <td class="centermid" id="txtplaytype"></td>
            <td class="centermid" id="txtpoints"></td>
            <td class="centermid" id="txtassists"></td>
          </tr>
        </table>
        <table width="120" border="0">
          <tr>
            <td><p class="centermid"><img src="Images/NBAlOGOSZ/093.png" name="imgcenter" width="133" height="117" id="imgcenter"></p></td>
          </tr>
</table>
        <table width="300" border="0">
          <tr>
            <td height="18" id="txtgameplay"><p class="centermid" id="txtgameplay">&nbsp;</p>
              <p>&nbsp;</p></td>
          </tr>
    </table>
        
      </div>
    <img src="Images/Courts/096.png" width="625" height="375"></div></td>
  </tr>
</table>
<script>
var myVar=setInterval(function(){myTimer()},1000);

function myTimer()
{

loadData();

}
</script>
</body>
</html>

Open in new window

Court3.html
18673.XML
0
Comment
Question by:powerztom
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39649067
No it work fine, to confirm place an alert after
 var assists = player.attr('Assists');
alert(assists); // first one is 0, second is 1

Open in new window

0
 

Author Closing Comment

by:powerztom
ID: 39649289
Thanks needed confirmation.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question