Solved

Unable to retrieve xml data.

Posted on 2014-01-16
4
263 Views
Last Modified: 2014-02-06
I wrote this code and I'm can tell you something is wrong strating with player's headshot.
I'm using classes for xml attribs also if you erase #template { display:none; } then you can see logo and title present but the next part not there. I used code that has worked in the past .

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.scrollbox.js"></script>
<script type="text/javascript">

	var xmlPath = '.' //'/xml/nba/scores/real';
	var xmlGameID = 'ADX-INDSTATS-PHI'; 

	$(document).ready(function() {
		var myVar = setInterval(getsimple, 10000);
		getsimple();
	});

	function getsimple() {
		$.get(xmlPath + "/" + xmlGameID + ".xml", function(data) {
			var d = $(data);
			var message = d.find('message');
			var title = $("Title", message).text();
			var teamid = $("TeamID", message).text();
			$('#title1').text(title);
			$('#teamid1').attr('src', 'http://images.sportsnetwork.com/nhl/attherink/logos/' + teamid + '.png');
			playerData = $(data);
			players = playerData.find('Individual_Stats');
			$('Player', players).each(function(i, player) {
				
			var newPlayer = $('#template').clone().removeAttr('id');
			 $('#NHLplayer').attr('src', 'http://images.sportsnetwork.com/nhl/attherink/players/'+ $('Player_ID', player).text() +".jpg");
           
			
			
			$('.pn', newPlayer).text( $('Player_Name', player).text() );
				$('.p', newPlayer).text( $('Position', player).text() );
			$('.j', newPlayer).text( $('Jersey_Number', player).text() );
				$('.gp', newPlayer).text( $('Games_Played', player).text() );
			$('.g', newPlayer).text( $('Goals', player).text() );
			$('.a', newPlayer).text( $('Assists', player).text() );
				
			$('.tp', newPlayer).text( $('Total_Points', player).text() );
			$('#players ul').append( $('<li>').append(newPlayer) );
		});
			
		$('#players').scrollbox({
		linear: true,
  step: 1,
  delay: 0,
  speed: 100
	
	
				
			});
		});
	}

</script>
<link rel="stylesheet" href="http://powerzsoftware.com/css/jquery-ui-1.8.9.customver1.css">
<style type="text/css">
	#players { width: 410px; height: 400px; overflow: hidden; }
	#players ul li { list-style-type: none; border-bottom:1px solid green; }
	.playerTable td { vertical-align:top; }
	
</style>
</head>

<body>
<div id="players" >
	<ul></ul>
</div>
<table id="template" class="playerTable" width="400" border="0">
  <tr>
    <td width="97"><div align="center"><img src="Logos/130.png" name="teamid1" width="50" height="50" id="teamid1"></div></td>
    <td colspan="6"><div align="center" id="title1"></div></td>
  </tr>
  <tr>
    <td rowspan="3"><div align="center"><img src="http://sportsnetwork.com/gamecast/Images/NHLPLAYER.png" name="NHLPlayer" width="50" height="50" id="NHLPlayer"></div></td>
    <td colspan="6" class="pn"><div align="center"></div></td>
  </tr>
  <tr>
    <td width="60"><div align="center">Position</div></td>
    <td width="22" class="p"><div align="center"></div></td>
    <td width="57"><div align="center">Jersey #</div></td>
    <td width="21"class="j"><div align="center"></div></td>
    <td width="90"><div align="center">Games Played</div></td>
    <td width="23" class="gp"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Goals</div></td>
    <td class="g"><div align="center"></div></td>
    <td><div align="center">Assists</div></td>
    <td class="a"><div align="center"></div></td>
    <td><div align="center">Total Points</div></td>
    <td class="tp"><div align="center"></div></td>
  </tr>
</table>
</body>
</html>

Open in new window


Thanks EE
jquery.scrollbox.js
ADX-INDSTATS-PHI.xml
fLYERS.html
0
Comment
Question by:powerztom
  • 2
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39785904
Hey Tom,

You have these lines:

players = playerData.find('Individual_Stats');
$('Player', players).each(function(i, player) {

Open in new window


This is looking for a node in your XML file called Player underneath the Individual_Stats node, but it doesn't exist, so your code never loops!
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39785970
You need to loop the players directly:

playerData.find('Individual_Stats').each(function(i, player) {
   ...
}

Open in new window

0
 

Author Closing Comment

by:powerztom
ID: 39786073
Chris,

Thanks alot I'm making Newbie mistakes but I feel I'm getting better.
I'm gonna put in another ticket cause Player's image is coming up and player Name isn't coming up. So if you want the points. Your always a great help. Thanks for Chris.
0
 

Author Comment

by:powerztom
ID: 39839904
Chris I could use your help on hockey mobile Didn't ready code just laided it out cause I'm not sure if Jquery Mobile is different syntax. This will be easy for you  and valuable resource for me. http://www.experts-exchange.com/Web_Development/Mobile_Web/Q_28358483.html
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

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

821 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