想在使用C#处理xml数据时请教一些建议。 我有一个小练习练习,我需要检索特定标签处的特定文本值。检索xml文本值
我已经将元素节点的各种名称分配给字符串值,并且用户需要向控制台输入字符串值,并且如果名称标记与输入相同,则检索定位在该标签。 这是我使用的C#代码,但我不知道如何检索名称标签处的文本值。
int priceSpecific;
string destination;
ArrayList array = new ArrayList();
xRootNode = xdoc.DocumentElement;
string firstValue = xRootNode.FirstChild.FirstChild.Name;
string secondValue = xRootNode.FirstChild.FirstChild.NextSibling.Name;
string thirdValue = xRootNode.FirstChild.FirstChild.NextSibling.NextSibling.Name;
string fourthValue = xRootNode.FirstChild.FirstChild.NextSibling.NextSibling.NextSibling.Name;
array.AddRange(new object[] { firstValue, secondValue, thirdValue, fourthValue});
Console.WriteLine("Please enter your destination, first letter capital");
destination = Console.ReadLine();
想法是循环arraylist并检索与用户的字符串输入相同的元素节点的名称。 有关如何检索文本值的任何建议?
Regards
你们是不是要选择按名称和它的值的节点? – varadarajan 2011-05-25 07:59:34