【发布时间】:2012-04-22 19:18:52
【问题描述】:
我是 C# 和 Windows Phone 开发的新手,如果我遗漏了明显的内容,请原谅我:
我想显示来自http://blog.dota2.com/feed/ 的 RSS XML 提要的缩略图。该图像位于用 HTML 编写的 CDATA 标记内。这是 XML 代码:
<content:encoded>
<![CDATA[
<p>We celebrate Happy Bear Pun Week a day earlier as Lone Druid joins Dota 2′s cast of heroes.</p> <p><a href="http://media.steampowered.com/apps/dota2/posts/LoneDruid_full.jpg "><img class="alignnone" title="The irony is that he's allergic to fur." src="http://media.steampowered.com/apps/dota2/posts/LoneDruid_small.jpg" alt="The irony is that he's allergic to fur." width="551" height="223" /></a></p> <p>Community things:</p> <ul> <li><a href="http://www.itsgosu.com/game/dota2/articles/ig-monthly-madness-invitational-finals-mar-29_407" target="_blank">It’s Gosu’s Monthly Madness</a> tournament finals are tomorrow, March 29th. You don’t want to miss this, we hear it could be more than we can bear.</li> <li>Bear witness to <a href="http://www.team-dignitas.net/articles/blogs/DotA/1092/Dota-2-Ultimate-Guide-to-Warding/" target="_blank">Team Dignitas’ Ultimate Guide to Warding</a>. This should be required teaching in clawsrooms across the globe.</li> <li>Great Explorer Nullf has <a href="http://nullf.deviantart.com/#/d4ubxiu" target="_blank">compiled the eating habits</a> of the legendary Tidehunter in one handy chart. This might give you paws before deciding to head to the beach.</li> </ul> <p>Bear in mind that there will not be an update next week as we will be hibernating during that time.</p> <p>Today’s bearlog is available <a href="http://store.steampowered.com/news/7662" target="_blank">here</a>.</p> <p> </p> <p>Bear.</p>
]]>
</content:encoded>
我只需要
<img src="http://media.steampowered.com/apps/dota2/posts/LoneDruid_small.jpg" />
所以我可以使用 URL 在我的阅读器应用中显示图像。
我听说有人说不要使用正则表达式,因为它是解析 HTML 的坏习惯。我将其创建为概念证明,无需担心。我正在寻找获取该图像 URL 的最快方法,然后在我的应用程序中调用它。
有人帮忙吗? 提前致谢, 汤姆
【问题讨论】:
-
只解析xml,简单多了!
-
对最好的方法有什么建议吗? :)
-
如果你坚持使用正则表达式试试这个 - stackoverflow.com/questions/4257359/…
标签: c# xml regex windows cdata