请发送 xml 样本以获取更多信息 。
Your code loads xml into dataset, so,
if your xml doesn t exported from DataSet, you could use LinqToXml.
for example:
xml :
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>Business Logic Toolkit for .NET</title>
<link>http://www.bltoolkit.net</link>
<description />
<lastBuildDate>2009-01-11</lastBuildDate>
<item>
<title>Version 3.1 released</title>
<link>http://www.bltoolkit.net/Download.htm</link>
<description>See <a href="http://www.bltoolkit.net/Download.htm">change log</a></description>
<pubDate>2009-01-11</pubDate>
</item>
<item>
<title>Version 3.0 released</title>
<link>http://www.bltoolkit.net/Download.htm</link>
<description>See <a href="http://www.bltoolkit.net/Download.htm">change log</a></description>
<pubDate>2008-05-21</pubDate>
</item>
<item>
<title>New examples</title>
<link>http://www.bltoolkit.net/Doc/</link>
<description>See the following <a href="http://www.bltoolkit.net/Doc/">link</a></description>
<pubDate>2008-05-10</pubDate>
</item>
</channel>
</rss>
此代码将获得所有 rss 项的标题
var path = @"D:
ss.xml";
var doc = XDocument.Load(path);
rssTitles = doc.Root.Descendants("item").Elements("title").Select(el => el.Value);
结果:
Version 3.1 released
Version 3.0 released
New examples