473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Yahoo Weather Feed

Hi there, I'm looking to display the Yahoo Weather feed on my website
(http://developer.yahoo.com/weather/). I am using Visual Web Developer
2005.

Everything works fine while parsing normal lines in the feed like this
(on the aspx page):

<asp:DataList ID="DataList1" runat="server"
DataSourceID="XmlDataSourceEd" Width="523px">
<ItemTemplate>
<%#XPath("title")%><br />
<%#XPath("description")%><br />
<%#XPath("lastBuildDate")%>
</ItemTemplate>
</asp:DataList>

But how would I get the <yweatherdata (with its attributes) to be
displayed, i.e. from the following XML file:
http://xml.weather.yahoo.com/forecastrss?p=UKXX0052&u=c

Using XPath, as above, does not work for <yweatherand I'm not sure
how this is done!

Best Regards,
Stewart.

Sep 15 '06 #1
9 3385

St******@vodafone.net wrote:
Everything works fine while parsing normal lines in the feed like this
(on the aspx page):

<asp:DataList ID="DataList1" runat="server"
DataSourceID="XmlDataSourceEd" Width="523px">
<ItemTemplate>
<%#XPath("title")%><br />
<%#XPath("description")%><br />
<%#XPath("lastBuildDate")%>
</ItemTemplate>
</asp:DataList>
Personally I wouldn't touch this stuff with a bargepole. It's the old
DSO approach, re-hashed with XPath kludged onto it. It still sucks as
much as DSO ever did. You'll have a happier life (and up to 40%
hair-regrowth) if you switch to using XSLT instead.
But how would I get the <yweatherdata (with its attributes) to be
displayed, i.e. from the following XML file:
http://xml.weather.yahoo.com/forecastrss?p=UKXX0052&u=c
yweather isn't an element, it's an XML namespace for some elements.
Easy enough with XPath, commonplace with XSLT and XPath, but I've no
idea how to do it in M$oft's ASP/XPath. It's probably easy, I just
don't know how. Try searching MSDN or the SDK help files and looking
for "XPath namespace"

Sep 15 '06 #2
Thanks Andy,

I'm relatively new to all this (hence my simple approach to it!) It
should be fairly straightforward - what I'm trying to - which is to
display a weather summary from the Yahoo feed.

I will get round to learning more about XML/XSLT, it's just that I need
a quick solution to this. (I'm particularly interested in the
hair-regrowth programme!)

I'll have another search on the web on XPath. In the mean time, does
anyone know a quick fix for this?

Cheers,
Stewart.

Sep 15 '06 #3
DataSourceID="XmlDataSourceEd" Width="523px">
<ItemTemplate>
<%#XPath("//yweather:forecast/@day")%><br />
<%#XPath("//yweather:forecast/@date")%><br />
<%#XPath("//yweather:forecast/@low")%><br />
<%#XPath("//yweather:forecast/@high")%><br />
<%#XPath("//yweather:forecast/@text")%><br />
</ItemTemplate>
</asp:DataList>

(or)

DataSourceID="XmlDataSourceEd" Width="523px">
<ItemTemplate>
<%#XPath("yweather:forecast/@day")%><br />
<%#XPath("yweather:forecast/@date")%><br />
<%#XPath("yweather:forecast/@low")%><br />
<%#XPath("yweather:forecast/@high")%><br />
<%#XPath("yweather:forecast/@text")%><br />
</ItemTemplate>
</asp:DataList>

Not work.

Else try to use MSXML parser method and transform the input XML
document to strip out those yweather prefixes. Let me know if you need
XSLT to do that.

St******@vodafone.net wrote:
Thanks Andy,

I'm relatively new to all this (hence my simple approach to it!) It
should be fairly straightforward - what I'm trying to - which is to
display a weather summary from the Yahoo feed.

I will get round to learning more about XML/XSLT, it's just that I need
a quick solution to this. (I'm particularly interested in the
hair-regrowth programme!)

I'll have another search on the web on XPath. In the mean time, does
anyone know a quick fix for this?

Cheers,
Stewart.
Sep 18 '06 #4

saratna...@gmail.com wrote:
<%#XPath("yweather:forecast/@day")%><br />
If this is really the right way to do it, then it's no wonder why
M$oft's products so often make me despair 8-(

It's a namespace, not a simple text prefix!

Sep 18 '06 #5
ok... then it seems like this is not working.
Do then you need to transform the input xml feed and strip it of all
namspace prefixes.

Create save this XSLT as a file and apply it on the input weather feed
before you pass it to your program.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>

<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>

<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

Source : http://www.tei-c.org.uk/wiki/index.p...Namespaces.xsl

Btw. - i am not a msft person. so i do not have much idea on the msft
api to do this.
Buddhiraju Saratnath
http://www.geocities.com/saratnathb

Andy Dingley wrote:
saratna...@gmail.com wrote:
<%#XPath("yweather:forecast/@day")%><br />

If this is really the right way to do it, then it's no wonder why
M$oft's products so often make me despair 8-(

It's a namespace, not a simple text prefix!
Sep 19 '06 #6

sa********@gmail.com wrote:
Do then you need to transform the input xml feed and strip it of all
namspace prefixes.
Namespaces are your friend, so use them, don't throw them away!

First of all though you'll need to register that namespace with the
processor (XSLT, or presumably DSO too) This is easy in XSLT, just use
a namespace on the <xsl:stylesheetelement. I don't know how you do it
for DSO, presumably there's an extra statement to use earlier on

Sep 19 '06 #7
Absolutely!

If you can declare the namespace in your DSO, do use it.
If it doesn't support namespaces, you might have to live with this
kludge!
Saratnath Buddhiraju

Andy Dingley wrote:
sa********@gmail.com wrote:
Do then you need to transform the input xml feed and strip it of all
namspace prefixes.

Namespaces are your friend, so use them, don't throw them away!

First of all though you'll need to register that namespace with the
processor (XSLT, or presumably DSO too) This is easy in XSLT, just use
a namespace on the <xsl:stylesheetelement. I don't know how you do it
for DSO, presumably there's an extra statement to use earlier on
Sep 19 '06 #8

sa********@gmail.com wrote:
If you can declare the namespace in your DSO, do use it.
This suggests that you can't
http://www.hanselman.com/blog/aspnet...amespaces.aspx
If it doesn't support namespaces, you might have to live with this
kludge!
There's no point at all in running it through an XSLT filter, just so
that you can then feed it to this ghastly old baggage from last
century. If you have to use XSLT, process it entirely with XSLT.

Sep 19 '06 #9
".... ghastly old baggage from last"

I like that description. :)

Sep 20 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: futureofphp | last post by:
Hi I am having a PHP based intranet home page. How can I add local weather forecast for the day to it? Is there any free weather forevast providers? I am interested in the local weather of Europe....
1
by: it hates me | last post by:
Hey gang, I hope you're all well and you're having an enjoyable week I'd love to be able to have a custom news feed on my web page through Javascript The only custom news feed I can find for...
3
by: Neal | last post by:
VC++ VS 2003 I am currently finishing up a weather bug program that receives data from the weather.com weather feed, just need some finishing touches. The one issue I have run into seems to be...
1
by: pmclinn | last post by:
I have the xml feed belowfrom this link: http://www.weather.gov/alerts/ct.rss I for the life of me can not get this data to format in a html table using client side scripting. Any help would be...
9
by: StewartS | last post by:
Hi there, I'm looking to display the Yahoo Weather feed on my website (http://developer.yahoo.com/weather/). I am using Visual Web Developer 2005. Everything works fine while parsing normal...
3
by: dawnrager | last post by:
Hi, everyone. I'm having a really difficult time pasting in generated code from the Weather Channel for a weather sticker for my webpage. This was the code sent to me via email: <!-- cut and...
1
by: nagabhargavi | last post by:
Hi, Can any one tell me how to display weather of a city enetred using text box in my web site using php like as in weather.com.
2
by: sandeep patil | last post by:
how to diplay the weather condiction on my webpage suppose i want to read weather from www.bbc.co.uk/weather.html how i can read it usin program
2
by: Craig M | last post by:
Our current intranet site displays the weather with a 7 day forecast. We have to manually enter all the weather info into a SQL DB using a web front end, but would like to use an RSS feed. All...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.