?
Solved

grabbing wrong set of xml data

Posted on 2013-12-05
4
Medium Priority
?
302 Views
Last Modified: 2013-12-09
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', 'http://sportsnetwork.com/gamecast/NBA/Images/teamnavs/'+$(Team).attr('ID')+".jpg");
 
        var Play = d.find('Play');
		var totals = Play.find("Team_Totals");
		
	
		  
		   $('#txtfgatt').html($(totals).attr('FGAtt'));
		   $('#txtfgmade').html($(totals).attr('FGMade'));
		  $('#txttresmade').html($(totals).attr('TresMade'));
		   $('#txttresatt').html($(totals).attr('TresAtt'));
		   $('#txtorebounds').html($(totals).attr('ORebounds'));
		   $('#txtdrebounds').html($(totals).attr('DRebounds'));
		  $('#txtassists').html($(totals).attr('Assists'));
		   $('#txtperfouls').html($(totals).attr('PerFouls'));
		    $('#txtsteals').html($(totals).attr('Steals'));
		   $('#txtturnovers').html($(totals).attr('Turnovers'));
		    $('#txtftmade').html($(totals).attr('FTMade'));
		   $('#txtftatt').html($(totals).attr('FTAtt'));
		   $('#txtblockedshots').html($(totals).attr('BlockedShots'));
		   $('#txtrebounds').html($(totals).attr('Rebounds'));
		    $('#txttfouls').html($(totals).attr('TechnicalFouls'));
		   $('#txtteamrebounds').html($(totals).attr('TeamRebounds'));
		    $('#txtteamtech').html($(totals).attr('TeamTechnicals'));
		   $('#txtteamturnovers').html($(totals).attr('TeamTurnovers'));
		   
		   
		   
		   }
	
	});
		  

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
18464.XML
TeamStatsH.html
0
Comment
Question by:powerztom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 39700032
You'll need to use the filter() function to get at the right set of data. Have a look a this:

$(document).ready(function() {
	$.ajax({
		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
0
 

Author Closing Comment

by:powerztom
ID: 39701260
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.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39701298
Cheers Tom,

Yards of Ale tend to get very messy, very quickly ;)
0
 

Author Comment

by:powerztom
ID: 39706967
Chris,

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 http://www.experts-exchange.com/editQuestion.jsp?qid=28314146
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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 …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

800 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