PDA

View Full Version : XML help needed


Silver Owl
10-11-2011, 05:37 PM
I've been playing around with the yahoo fantasy sports API but can't get past this problem. I am just trying to pull data from an XML file but can't pull anything from this line

the XML code is :
>?xml version="1.0" encoding="UTF-8"?<
>query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2011-10-11T22:16:44Z" yahoo:lang="en-US"<
>results<
>league xmlns="http://fantasysports.yahooapis.com/fantasy/v2/base.rng"<
>league_key<242.l.9137>/league_key<
>league_id<9137>/league_id<
>/league<
>/results<
>/query<


and the XSLT code is :

>?xml version="1.0" encoding="ISO-8859-1"?<
>!-- Edited by XMLSpy® --<
>xsl:stylesheet version="1.0
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<
>xsl:template match="/"<
>html<
>body<
>h2<League Info>/h2<
>table border="1"<
>tr bgcolor="#9acd32"<
>th<Key>/th<
>th<ID>/th<
>/tr<
>tr<
>td<>xsl:value-of select="query/results/league/league_key"/<>/td<
>td<>xsl:value-of select="query/results/league/league_id"/<>/td<
>/tr<
>/table<
>/body<
>/html<
>/xsl:template<
>/xsl:stylesheet<

I can't pull anything past the bolded line.
I am very inexperienced with this so any help would be greatly appreciated.

edit - I reversed all of the > < to get the code to show up.

gstelmack
10-11-2011, 05:40 PM
You need to code-bracket that or something, the XML is not coming through.

Silver Owl
10-12-2011, 02:38 PM
You need to code-bracket that or something, the XML is not coming through.

Thanks, I think its showing up now.

Silver Owl
10-14-2011, 02:39 PM
anyone?

Matthean
10-14-2011, 03:25 PM
I don't know enough to answer your question, but I was looking around on Yahoo's site and the "xmlns='http://fantasysports.yahooapis.com/fantasy/v2/base.rng'" part was in the same tag as xmlns:yahoo. If Yahoo's site has a forum for this kind of stuff, I would look there. webdeveloper and sitepoint fourms would be a couple web dev. forums worth looking at for places to get feedback as well.

Ronnie Dobbs2
10-14-2011, 03:41 PM
Not experienced with XSLT.

Is it a permissions thing? Opening http://fantasysports.yahooapis.com/fantasy/v2/base.rng yields an OAuth credentialing problem.

Radii
10-14-2011, 04:13 PM
yeah i've never done enough with xslt to get any sort of nuances with it, but I know the namespace elements (xmlns) add a level of complication to it and that is likely what's screwing you up, I just don't know how to deal with it.

Silver Owl
10-15-2011, 07:02 AM
Thanks guys, Radii is correct that the namespace element is the problem. I just can't figure out how to get around it. It doesn't help that I also don't know what I am doing.

Ronnie Dobbs2
You are right about the permissions. Yahoo has a console where you can get XML data without the permissions. In order to use the data on a website you have to go through the OAuth process.

Matthean
I will search some webdeveloper and sitepoint fourms.

thanks guys

Ronnie Dobbs2
10-15-2011, 10:18 AM
One thing you might want to try is avoiding the XML altogether and using the Yahoo! Query Language. Works seemlessly with AJAX calls and can return JSON which is a breeze to work with. I believe support for Yahoo! Fantasy is provided.

http://developer.yahoo.com/yql/

Silver Owl
10-15-2011, 01:34 PM
One thing you might want to try is avoiding the XML altogether and using the Yahoo! Query Language. Works seemlessly with AJAX calls and can return JSON which is a breeze to work with. I believe support for Yahoo! Fantasy is provided.

http://developer.yahoo.com/yql/

I will look into that. Thanks