从c#中的rss feed中提取数据
我需要从下面的 xml 文档中读取 woeid。我需要读取数据并将其存储到字符串变量中,以便可以查询雅虎天气服务。
查询返回的 XML:
<query yahoo:count="1"
yahoo:created="2009-12-22T08:30:31Z"
yahoo:lang="en-US"
yahoo:updated="2009-12-22T08:30:31Z"
yahoo:uri="http://query.yahooapis.com/v1/yql?q=select+woeid+from+geo.places+where+text%3D%22farnborough%2C+greater+london%2Cuk%22">
−
<diagnostics>
<publiclyCallable>true</publiclyCallable>
−
<url execution-time="32">
http://where.yahooapis.com/v1/places.q(farnborough%2C%20greater%20london%2Cuk);start=0;count=10
</url>
<user-time>33</user-time>
<service-time>32</service-time>
<build-version>4265</build-version>
</diagnostics>
−
<results>
−
<place>
<woeid>19941</woeid>
</place>
</results>
</query>
有人可以告诉我如何通过 linq 执行此操作吗?
- - - - - 编辑 - - - - - - - - - - - - - - - - - - - - -------------------------------------------------- -
我刚刚意识到 .net 2.0 不支持 linq...doh
所以请有人建议使用 .net 2.0 提供的参考资料的替代方法吗? -也许重新发布并标记? 非常感谢,
I need to read the woeid from the xml doc below. I need to read and store the data into a string variable so I can query the yahoo weather service.
XML returned by query:
<query yahoo:count="1"
yahoo:created="2009-12-22T08:30:31Z"
yahoo:lang="en-US"
yahoo:updated="2009-12-22T08:30:31Z"
yahoo:uri="http://query.yahooapis.com/v1/yql?q=select+woeid+from+geo.places+where+text%3D%22farnborough%2C+greater+london%2Cuk%22">
−
<diagnostics>
<publiclyCallable>true</publiclyCallable>
−
<url execution-time="32">
http://where.yahooapis.com/v1/places.q(farnborough%2C%20greater%20london%2Cuk);start=0;count=10
</url>
<user-time>33</user-time>
<service-time>32</service-time>
<build-version>4265</build-version>
</diagnostics>
−
<results>
−
<place>
<woeid>19941</woeid>
</place>
</results>
</query>
Can someone show me how to do this through linq?
----------EDIT ------------------------------------------------------------------------------------------
I've just realised i linq is not supported by .net 2.0...doh
So please could some suggest an alternative way using references available with .net 2.0? -maybe repost and tag?
Many Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以这样做:
You can do it like this:
您可以使用类似于此 Linq 查询的方法从 XML 文档中获取结果
You can use something similar to this Linq query to get the results back from the XML document
这里是一种使用 Linq 和 xPath 从 xml 文件中提取值的方法。
希望这对一些人有帮助。
Here is a way to extract values from an xml file using Linq and xPath.
Hope this helps some.