Dropdown/XML to Data Table

Hello,

I created a table in my DashBoard with three columns (Team Name, Tricode, and Team Mascot) that displays info for multiple teams. I have all my teams within a xml file, separated by league. I’d like to be able to select the correct league from a separate dropdown and have the table populate with team info from only that league. I have attached the scripting I’m using on the dropdown parameter (Select_AWAY_League) as well as a trimmed down version of the xml file I’m using.

The scripting works fine if there’s no league separation in the xml file so I’m guessing I have a problem with one of the root elements. But I figured if the dropdown parameter string value matched the league name within the xml, it would just follow that path and parse the values. What am I doing wrong?

Thanks!

Hi Robert.

My guess would be that you have a problem with the value of your “league” variable matching your XML tags. The XPath you’re using is otherwise a correct match for the XML you’ve produced. If I run the XPath with the league name hard-coded, I get the expected results:

var xml =‘<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’ +
‘\n’;

var xmlObj = ogscript.parseXML(xml);
var found = ogscript.runXPath(‘all/PAC10/team’, xmlObj);

var foundTeamList = “”;
for (var i = 0; i < found.length; i++)
{
foundTeamList += found.item(i).getAttribute(‘name’) + " ";
}

ogscript.debug("FOUND " + foundTeamList);
#DashBoard

Turns out the code was good the entire time and it was me who turned out to be the idiot.

My complete xml had all the college conferences listed as their complete names (ATLANTIC 10, BIG TEN, IVY LEAGUE, etc.) including those spaces. When I trimmed it down to post the question, I didn’t actually test that xml with “A10”, “PAC10” and “BIG10” - because that would have worked…even with the string value of the league parameter.

Don’t be an idiot like me. Use underscores instead of spaces in your xmls.

Thanks guys.

#DashBoard