grabbing wrong set of xml data

There are two sections in this xml doc that have total team stats I located in the middle and one at the bottom. The page for the away team works fine but the page for the home team displays the home team logo but displays away team 's total team stats. And that's because a EE guy once told me that the code I have written will only pull up first set of stats even though I do this

 if ($(Team).attr('vh') == "H") {

                        $('#imgteam').attr('src', ''+$(Team).attr('ID')+".jpg");
        var Play = d.find('Play');
		var totals = Play.find("Team_Totals");

Open in new window


I just can't find that piece of code matching this case. If you get Memphis starting with FGAtt="86" then you got the right total team stats
Who is Participating?
Chris StanyonConnect With a Mentor Commented:
You'll need to use the filter() function to get at the right set of data. Have a look a this:

$(document).ready(function() {
		url:  'data.xml'
	.done(function(data) {
		var gameData = $(data);
		var team = $('Team', gameData).filter(function() { return $(this).attr('vh') == 'H' });
		var teamTotals = $('Team_Totals', gameData).filter(function() { return $(this).attr('IS_TeamID') == team.attr('ID')} );

Open in new window

Line 7 in the code above filters the team on the value of vh. The above looks for the Home Team - if you want the away team, change the H for A
powerztomAuthor Commented:
Chris thank you I love this site cause I am learning some much. Not from the Idiot in the cubical next to me but from maybe the best in the IT World. Chris I owe you a steak dinner with a couple yards did I say that right Yards are long glasses of beer in England? Thanks again Chris you are good.
Chris StanyonCommented:
Cheers Tom,

Yards of Ale tend to get very messy, very quickly ;)
powerztomAuthor Commented:

How are you doing ?Good I hope. We I got two more hockey projects to do then I am done. Gamecast project. I got one I started using so of your code which should easily work but I have two dropdowns and I need header to stay frozen like excel scrolling but the header stays. I split the project in two so in this one you do  and don't have to be ready with current play cause this is a game log I want the current play to display in the canvas projects and this project  just grabs the Peroid's actions so it just selectes peroid 1 and all of peroid 1 after peroid 1 it  goto just scooping up peroid 2 and on to peroid 3 you get the idea. But the program has to check quarter attribute to load Icelog. I'm doing it this way cause for some reason when it's live it just grabs 5 or 6 recent plays and the seq number jumps up and down the value couls be 1000234 then the next seq number may be 1000244 then after that 1000220. The feed is from Canada or NHL so Their system makes not much sense. SO QUERING THAT QUARTER INSTEAD OF SEQ NUMBER SHOULD BE BETTER. Anyway if you read this all I thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.