首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基于WP8的C#解析器

基于WP8的C#解析器
EN

Stack Overflow用户
提问于 2014-08-18 12:23:39
回答 1查看 88关注 0票数 1

我一直试图根据下载的xml字符串元素将其转换为列表,但似乎找不到解决方案。我的目标是得到艺术家的名字。

以下是xml页面的摘录:

代码语言:javascript
运行
复制
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.10.2">
  <artists ignoredArticles="The El La Los Las Le Les">
      <index name="A">
         <artist id="15" name="A Tribe Called Quest" coverArt="ar-15"    albumCount="5"/>
         <artist id="2" name="A$AP Ferg" coverArt="ar-2" albumCount="1"/>
         <artist id="11" name="A$ap Mob" coverArt="ar-11" albumCount="1"/>
         <artist id="353" name="A$AP Rocky" coverArt="ar-353" albumCount="3"/>
         <artist id="382" name="A-1" coverArt="ar-382" albumCount="3"/>
         <artist id="9" name="A1 Bassline & Rusko" coverArt="ar-9" albumCount="1"/>
         <artist id="25" name="Aaliyah" coverArt="ar-25" albumCount="7"/>
         <artist id="1" name="Ab-Soul" coverArt="ar-1" albumCount="4"/>
         <artist id="50" name="Ace Hood" coverArt="ar-50" albumCount="18"/>
         <artist id="134" name="Adele" coverArt="ar-134" albumCount="4"/>
         <artist id="283" name="Aesop Rock & Del Tha Funky Homosapien" coverArt="ar-283" albumCount="1"/>
         <artist id="92" name="Afroman" coverArt="ar-92" albumCount="10"/>
         <artist id="280" name="Akinyele" albumCount="1"/>
         <artist id="421" name="Akira Kosemura" albumCount="1"/>
         <artist id="163" name="Akon" coverArt="ar-163" albumCount="20"/>
         <artist id="152" name="Akon, T-pain" albumCount="1"/>
         <artist id="106" name="All Saints" coverArt="ar-106" albumCount="1"/>
         <artist id="287" name="Almighty" coverArt="ar-287" albumCount="1"/>
         <artist id="176" name="Amanda Blank" coverArt="ar-176" albumCount="1"/>
         <artist id="56" name="ASIAN KUNG-FU GENERATION" coverArt="ar-56" albumCount="6"/>
         <artist id="374" name="Atmosphere" albumCount="11"/>
         <artist id="105" name="Attaca Pesante" coverArt="ar-105" albumCount="1"/>
         <artist id="190" name="Audio Bullys" coverArt="ar-190" albumCount="1"/>
         <artist id="44" name="August Alsina" coverArt="ar-44" albumCount="1"/>
     </index>
<index name="B">
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-18 12:31:21

这是我的想法,但你必须先创建“名字”列表。试试这个:

代码语言:javascript
运行
复制
XDocument xDoc = XDocument.Load("your xml file");
foreach (var elem in xDoc.Document.Descendants("artist"))
{
    names.Add(elem.Attribute("name").Value);
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25363233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档