读取XML某一节点下面的所有子节点的值
<display>
<website></website>
<siteurl></siteurl>
<city></city>
<category></category>
<dpshopid/>
<range/>
<address>
</address>
<major></major>
<title></title>
<image>
</image>
<startTime></startTime>
<endTime></endTime>
<value></value>
<price></price>
<rebate></rebate>
<bought></bought>
</display>
怎么得到display下面各个节点的值,C#
------解决方案--------------------
C# code
string result = "";
XmlDocument xmldocument = new XmlDocument();
xmldocument.LoadXml(result);
XmlNodeList node = xmldocument.SelectNodes("//display");
foreach (XmlNode n in node)
{
string id = n.SelectSingleNode("website").InnerText;
string RName = n.SelectSingleNode("siteurl").InnerText;
}
------解决方案--------------------
XmlNodeList node = xmldocument.SelectNodes("//display");
然后遍历node
------解决方案--------------------
------解决方案--------------------
XmlDocument doc=new XmlDocument();
doc.Load("");
foreach (XmlNode node in doc.GetElementsByTagName(""))
{
foreach (XmlNode xn in node.ChildNodes)
{
Console.WriteLine(xn.InnerText);
}
}
或
XDocument Doc = XDocument.Load(@"");
var Query = from D in Doc.Elements("")
select D;