[英]WP8 Xml parser in C#
I've been trying to convert a downloaded xml string into Lists based on their element, but I can't seem to find a solution. 我一直在尝试根据其元素将下载的xml字符串转换为List,但似乎找不到解决方案。 My goal is to get the artist name. 我的目标是获得艺术家的名字。
Here is an excerpt of the xml page: 这是xml页面的摘录:
<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">
Here is my idea but you have to create list "names" before. 这是我的想法,但是您必须在之前创建列表“名称”。 Try this: 尝试这个:
XDocument xDoc = XDocument.Load("your xml file");
foreach (var elem in xDoc.Document.Descendants("artist"))
{
names.Add(elem.Attribute("name").Value);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.