Solved

Pulling most but not all xml data.

Posted on 2014-01-16
8
196 Views
Last Modified: 2014-02-07
I'm not pulling the player headshot ID = NHLplayer and Player_Name= pn run the html file and you will see

<!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');
			playerData.find('Individual_Stats').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).html() );
				$('.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: 435px; height: 400px; overflow: hidden; }
	#players ul li { list-style-type: none; border-bottom:1px solid green; }
	.playerTable td { vertical-align:top; }
	#template { display:none; }
</style>
</head>

<body>
<div id="players" >
	<ul></ul>
</div>
<table id="template" class="playerTable" width="400" border="0">
  <tr>
    <td width="73"><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="84"><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

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

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39786174
Hey Tom.

If you look at your XML data, you'll see that Player_Name is an attribute of the Individual_Stats node, and not a node in itself, so instead of:

$('.pn', newPlayer).text( $('Player_Name', player).html() );

You need this:

$('.pn', newPlayer).text( $(player).attr('Player_Name') );

The headshot isn't showing for a couple of reasons - firstly, you have a case-mismatch - NHLplayer in the jQuery and NHLPlayer in the HTML (note the capital P).

You're also using an ID where you should be using a class. You should have this in your jQuery:

$('.NHLPlayer').attr('src', 'http://images.sportsnetwork.com/nhl/attherink/players/'+ $('Player_ID', player).text() +".jpg");
           
And this in your HTML:

<img src="http://sportsnetwork.com/gamecast/Images/NHLPLAYER.png" width="50" height="50" class="NHLPlayer">
0
 

Author Closing Comment

by:powerztom
ID: 39786233
Chris thanks for the insight on "look at your XML data, you'll see that Player_Name is an attribute of the Individual_Stats node, and not a node in itself, so instead of:"

And Image now appears but it's the same headshot for every table. I'm gonna give these points and Put in one last ticket for repeating headshot. Chris I'm glad your back cause your code is always sharp.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39786256
Wish I was still on holiday :)

Make sure you've changed the NHLPlayer bit from using an ID to using a class (both in jQuery and HTML!)
0
 

Author Comment

by:powerztom
ID: 39786434
Coming Back to the work world sucks after a vacation no doubt. Chris I got NHLPlayer named this why in both html and Jquery. This one now is above me I think the same image that keeps repeating is the last record like the code for the image runs to the end while everything else is incrementing. Cause that head shot is not Claude Giroux IT'S Ray Emery who is the last player on the xml file. For image it just goes straight to last value and remains there for some reason. Give the html file a click check it out.Html File
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39786505
Post your HTML page as you have it- you've only posted an image so I can't examine that! I'm sure it's something simple :)
0
 

Author Comment

by:powerztom
ID: 39842569
Chris could you please give me a hand on my ticket You can get this done easily I'm trying to piece some of your code which is good but I can't come up with desired result. Please could you work your magic http://www.experts-exchange.com/Web_Development/Mobile_Web/Q_28358483.html
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39842591
Flat out with work at the moment so haven't really got time to look at it. I may get a chance over the weekend but no guarantees ;(
0
 

Author Comment

by:powerztom
ID: 39843037
No problem Chris If you get to it I appreciate and if not you got to take care of yourself first
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
control character echo in html input field with javascript or jquery 7 35
regx  exclude  pattern 6 29
JavaScript: Issue with onClick 5 36
Enter key on html form page 11 48
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now