獲取IMG SRC我是新來的C#和Windows Phone開發所以請原諒我,如果我錯過了很明顯的:從XML CDATA
我想從位於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,然後在我的應用程序中調用這個。
有沒有人有任何幫助?當你 由於提前, 湯姆
返回的
html
只是解析xml,它是如此簡單! – scibuff 2012-04-10 13:37:32任何建議爲最好的方式來做到這一點? :) – 2012-04-10 13:38:36
如果你堅持正則表達式試試這個 - http://stackoverflow.com/questions/4257359/regular-expression-to-get-the-src-of-images-in-c-sharp – scibuff 2012-04-10 13:41:17