62,074
社区成员
发帖
与我相关
我的任务
分享
<display>
<website>website</website>
<siteurl>siteurl</siteurl>
<city>city</city>
<category>category</category>
<dpshopid/>
<range/>
<address>address</address>
<major>major</major>
<title>title</title>
<image>image</image>
<startTime>startTime</startTime>
<endTime>endTime</endTime>
<value>value</value>
<price>price</price>
<rebate>rebate</rebate>
<bought>bought</bought>
</display>
string str = "";
string path = Server.MapPath("XMLFile.xml");
XmlDocument xml = new XmlDocument();
xml.Load(path);
XmlNode node = xml.SelectSingleNode("display");
foreach (XmlNode n in node)
{
str += "Name:" + n.Name + " Value:" + n.InnerText + "<br/>";
}
Response.Write(str);
/*
结果:
Name:website Value:website
Name:siteurl Value:siteurl
Name:city Value:city
Name:category Value:category
Name:dpshopid Value:
Name:range Value:
Name:address Value:address
Name:major Value:major
Name:title Value:title
Name:image Value:image
Name:startTime Value:startTime
Name:endTime Value:endTime
Name:value Value:value
Name:price Value:price
Name:rebate Value:rebate
Name:bought Value:bought
*/
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;
}