Trying to process Attributes for a Simple Mashup

vanolind
User offline. Last seen 26 weeks 2 days ago. Offline
Joined: 07/17/2009
Points: 30

Hey guys, I know this is a silly question, but I'm trying to make my own simple mashup utilizing the YahooWeatherRest service and I'm running into a snag.  I dont know if its a problem with me being new to EMML, or XPath, or just new in general. but any help could be appricated.

After I send a zipcode to the service, I get all the information I need.

However one of the lines has attributes which I cannot seem to get at.

<yweather:condition code="34" date="Wed, 22 Jul 2009 11:15 am EDT" temp="86" text="Fair">         </yweather:condition>

Is there a command to grab the attribute values?  The Eclipse complier, when i try to run the script, doesn't like it when I do anything involving the colon in yweather:condition.  I tried to use a filter to get the code, date, temp, and text, but I suppose I just don't know the syntax well enough to get them.

http://developer.yahoo.com/weather/ Has all the information on how the elements are formatted.

 

Thanks guys!  I bet its somthing really simple...

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 18 hours 3 min ago. Offline
Joined: 08/29/2008
Points: 34

That colon is part of the namespace prefix for the condition element. Have you added the yweather namespace to your mashup script?

If not, you need to declare that namespace on the <mashup> element. Something like this:

<mashup
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.jackbe.com/2008-03-08/EMMLSchema/../src/schemas/EMMLSpec.xsd"
  xmlns:yw="http://xml.weather.yahoo.com/ns/rss/1.0"
  xmlns="http://www.jackbe.com/2008-03-08/EMMLSchema">

You *don't* have to use "yweather" as the prefix for the namespace, but the URI that Yahoo! uses for that namespace must match. You will find that URL in the response, also declared on <rss>.

Once you add the namespace, then an Xpath expression such as this ought to work to access the temperature attribute: 

$result/yw:condition/@temp

 

Sara, technical writer/jackbe