【发布时间】:2014-05-19 19:24:54
【问题描述】:
谁能告诉我如何在 Windows phone 8 中使用 XDocument 解析这种格式的 XML
<search total="" totalpages="">
<domain>
<makes filter="">
<make cnt="374" image="abc.png">One</make>
<make cnt="588" image="bca">Two</make>
<make cnt="105" image="tley.png">Three</make>
<make cnt="458" image="mw.png">Four</make>
</makes>
</domain>
</search>
现在我正在使用此代码,但无法获取数据。我需要这个 XML 中的图像和名称。
XDocument xdoc = XDocument.Parse(flickRes);
var rootCategory = xdoc.Root.Elements("makes");
List<string> list = new List<string>();
foreach (XElement book in rootCategory.Elements("make"))
{
string id = (string)book.Attribute("image");
string name = (string)book;
Debug.WriteLine(id);
//list.Add(data);
}
提前致谢
【问题讨论】:
标签: c# .net xml windows-phone-8 linq-to-xml