如何选择xml属性值,然后选择其chilb元素 [英] how to select xml attribute value and then select its chilb element
本文介绍了如何选择xml属性值,然后选择其chilb元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
my xml
my xml
<items>
<
i want to bind the item 2 name in list box
my c#
<pre lang="c#">
private void cmbecg_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cmbecg.SelectedIndex == 1)
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(@"F:\tuner4tronics\t4tdevicedescriptor\t4tdevicedescriptor\ecgdiscription.xml");
XmlNodeList ecglistfeatures = xdoc.SelectNodes("items/item/features/name");
if (lst1.Items.Count == 0)
{
foreach (XmlNode name in ecglistfeatures)
{
lst1.Items.Add(name.InnerText.Trim());
}
}
}
else if (cmbecg.SelectedIndex == 2) !!!!!!here i want to bind item 2 name !!!!!!!
{
lst1.Items.Clear();
XmlDocument xdoc = new XmlDocument();
xdoc.Load(@"F:\tuner4tronics\t4tdevicedescriptor\t4tdevicedescriptor\ecgdiscription.xml");
XmlNodeList ecglistfeatures = xdoc.SelectNodes("items/item/attribute[id='2']/name");
if (lst1.Items.Count == 0)
{
foreach (XmlNode name in ecglistfeatures)
{
lst1.Items.Add(name.InnerText.Trim());
}
}
}
}
推荐答案
嗯,我认为这很简单。
见下这个aritlces。
http://forum.codecall.net/topic/58239-c-tutorial-reading-and-writing-xml-files/ [ ^ ]
http://csharp.net -informations.com/xml/how-to-read-xml.htm [ ^ ]
http:// www。 dotnetperls.com/xmlreader [ ^ ]
我希望这对你有帮助。
Well, I think it's very simple.
See under this aritlces.
http://forum.codecall.net/topic/58239-c-tutorial-reading-and-writing-xml-files/[^]
http://csharp.net-informations.com/xml/how-to-read-xml.htm[^]
http://www.dotnetperls.com/xmlreader[^]
I hope this will be help you.
这篇关于如何选择xml属性值,然后选择其chilb元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文