<channel>
<title>test + test</title>
<link>http://testprog.test.net/api/test</link>
<description>test.com</description>
<category>test + test</category>
<item xml:base="http://test.com/test.html?id=25>
<guid isPermaLink="false">25</guid>
<link>http://test.com/link.html</link>
<title>title test</title>
<description>Description test description test</description>
<a10:updated>2015-05-26T10:23:53Z</a10:updated>
<enclosure type="" url="http://test.com/test/test.jpg" width="200" height="200"/>
</item>
</channel>
このタグ(タイトルテスト)を次のように抽出しました。
title = ds.Tables["item"].Rows[0]["title"] as string;
c#で
<encosure>
タグからurl属性を抽出する方法は?
どうも
最初のオプション
クラスを作成して、XMLをオブジェクトにマップおよび逆シリアル化し、プロパティとして簡単にアクセスできます。
2番目のオプション
少数の値のみに関心があり、マッピングクラスを作成したくない場合は、
XPathを使用できます。簡単に見つけることができる多くの記事や質問が用意されています。
タグからurl属性を抽出するには、パスを使用できます。
"/channel/item/enclosure/param[@name='url']/@value"