+1
Résolu
Simple RSS parsing help needed
Hello, newbie here looking for the best way to access one element within a simple RSS feed. I am writing a weather app as practice, and I'd like to use one of the popular weather status RSS feeds to determine current conditions in a zip code. I've looked at the Yahoo weather RSS feed, and their "code" element is exactly what I need. I've gone through the tutorial on using datasources, and it makes sense, Im just having trouble simplifying it down to my need. I've created a timed loop in my app that wants to check this "code" element, and then display an icon based on the results. Any advice on the simplest way to access that one piece of info? Here is a link to the RSS feed: http://weather.yahooapis.com/forecast...
Thanks in advance.
Thanks in advance.
Service d'assistance aux clients par UserEcho
You are right, the attribute inside of a node can be a little tricky to path to with XPath. Here is a simple datasource wire that is using a list and an object tag to parse down to the 'code' element in your feed. I hope this helps.
<object class="article-list-item" dataSourceIndex="[param:dataSourceIndex]" headline="[param:title]" description="[param:*[local-name()='forecast']/@code]" />
-What's your recommendation for creating the time delayed function that checks for a new weather code every x minutes? I tried a tag with a delay, but I'm getting odd results.
- Seems like I have to use a class/object to get the RSS weather code into the app, how do I pass that code back down to an action where I can use it to feed the video controller source?
- Finally, how would you approach this project (in other words, am I going about it all wrong)?
Thanks for your help. I love this application, and I want to start using it more frequently, so I'm trying to get comfortable with the developer tools.
The code could look something like this:
<action name="check-weather" oninit="yes" onresume="yes">
<sync loop="yes" delay="60">
<play action="weatherdata" />
</sync>
</action>
<action name="weatherdata">
<if lhs="[datasource:weather.1.condition]" operator="e" rhs="23">
PLAY SUNNY VIDEO
</if>
IF...etc.
</action>
2) When you are using a class, you can treat it just like you would any other object in the main block, meaning that you can place onclicks, etc. onto the class and those can fire actions. You can also add object variables (_something) that actions fired directly on the object can read.
EX.
<class name="amigos">
<panel name="[param:name]" width="15%" height="60%" xpos="[param:x]" ypos="33%" onclickup="set-variable" _amigo="[param:amigo]"></panel>
</class>
.....
<action name="set-variable">
<assign property="var:amigo" value="_amigo" />
<alpha value="1" time="0" target="PANEL" />
<assign property="object:TEXT.text" value="Starring [var:amigo]!" />
</action>
3) Listening to you talk about the project sounds like you have a lot figured out already. We are glad you like it so far. If you want to send me a collaborator invite I would love to take a look at the code and see how it is going!
Thanks.
Looking forward to seeing it.