grabbing wrong set of xml data

Posted on 2013-12-05
Medium Priority
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");

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
Question by:powerztom
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
LVL 44

Accepted Solution

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() {
		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

Author Closing Comment

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.
LVL 44

Expert Comment

by:Chris Stanyon
ID: 39701298
Cheers Tom,

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

Author Comment

ID: 39706967

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

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
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)
Suggested Courses

649 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