0
我試圖格式化並獲取圖像,文本等等,以提供良好的外觀和感覺。使用C#中的C#XDocument或XPath從RSS格式化CDATA類型
的XML是這樣的:
xmlns:content="http://purl.org/rss/1.0/modules/content/"
,內容是:
<content:encoded>
<![CDATA[
<p><a href="http://i2.wp.com/geekytheory.com/wp-content/uploads/2014/03/Screen-Shot- 2013-11-11-at-11.38.50.png"><img class="size-full wp-image-7447 aligncenter" alt="Screen Shot 2013-11-11 at 11.38.50" src="http://i2.wp.com/geekytheory.com/wp- content/uploads/2014/03/Screen-Shot-2013-11-11-at-11.38.5
]]>
<![CDATA[
0.png?resize=788%2C644" data-recalc-dims="1" /></a></p> <p style="text-align: justify">
</p>]]>
< /content:encoded>
起初什麼,我會得到的是圖像或例子:他是在內容:編碼/ p/A/IMG/src目錄
的代碼,我嘗試是:
。的內容= i.Element(xmnsContent +「編碼」)值給我所有的未格式化的內容是這樣的:
而對於exctract圖像或從其他元素CData我得到一個錯誤。 Image = i.Element(xmnsContent +「encoded」)。XPathSelectElement(「// p // a // img [@src]」)。值給出錯誤。
我也試過這種方式,但給出了同樣的錯誤。
Image = i.Element(xmnsContent+"encoded").Element("p").Element("a").Element("img").Attribute("src").Value
謝謝你的問候!
沒有人可以幫助我嗎? :( – soydachi