如何在Windows Phone中将数据从xml填充到列表框?
我想填充这个xml如何在Windows Phone中将数据从xml填充到列表框?,xml,windows,windows-phone-7,mobile,listbox,Xml,Windows,Windows Phone 7,Mobile,Listbox,我想填充这个xml <head xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/"> <arm> <fingers> <middle>1</middle> <m
<head xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
<arm>
<fingers>
<middle>1</middle>
<middle>2</middle>
</fingers>
<fingers>
<middle>3</middle>
<middle>4</middle>
</fingers>
</arm>
</head>
1.
2.
3.
4.
我希望在列表框中显示此数据的文件如果要在列表框中显示中间标记内容列表,则不能尝试以下方法:
var xml = @"<head xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://tempuri.org/"">
<arm>
<fingers>
<middle>1</middle>
<middle>2</middle>
</fingers>
<fingers>
<middle>3</middle>
<middle>4</middle>
</fingers>
</arm>
</head>";
var doc = XDocument.Parse(xml);
XNamespace xmlNamespace = "http://tempuri.org/";
var middles = from middle in doc.Descendants(xmlNamespace + "middle") select middle.Value;
MyListBox.ItemsSource = middles;
var xml=@”
1.
2.
3.
4.
";
var doc=XDocument.Parse(xml);
XNamespace xmlNamespace=”http://tempuri.org/";
var middles=从doc.subjects中的中间位置(xmlNamespace+“middle”)选择middle.Value;
MyListBox.ItemsSource=middles;
上面的代码使用linq to xml只查询
标记内的值。然后在MyListBox
中显示查询结果,如果有另一个标记怎么办?在中间之后?例如,我想把它也展示出来?你应该把它作为一个新问题发布。解决方法取决于
中是否有其他标记,或者(
和
)是
中唯一的标记。但在进入下一个问题之前,你们之前的问题并没有一个答案被接受,这一事实非常令人困扰。如果你发现你的问题有任何有用的答案,请向上投票,如果它对你有用。