这样的XML如何读取
- <dds>
- <dd>
<rowno>1</rowno>
<ID>5931</ID>
<GUID>A22D5995-11F9-4506-9A2A-126CCA9F0F31</GUID>
<DJBH>DD00011296</DJBH>
<RQ>2013-01-14T13:17:20</RQ>
<LYDH>188961743647240</LYDH>
- </dds>
- </dd>
想读取ID中间的值:5931,请问如何读取?
以下是我可以循环得出的值,但如何判断是ID的值呢?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"http://。。。。。");
XmlNodeList nodeList = xmlDoc.SelectSingleNode("dds/dd").ChildNodes;
foreach (XmlNode node in nodeList)
{
foreach (XmlNode n2 in node.ChildNodes)
{
MessageBox.Show(n2.InnerText ); //我这里能循环读出,但怎么判断这个值是ID的呢?
}
}
xml
------解决方案--------------------
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"http://。。。。。");
XmlNodeList nodeList = xmlDoc.SelectSingleNode("dds/dd").ChildNodes;
foreach (XmlNode node in nodeList)
{
foreach (XmlNode n2 in node.ChildNodes)
{
if(n2.Name=="ID"){ //这里判断
}
MessageBox.Show(n2.InnerText ); //我这里能循环读出,但怎么判断这个值是ID的呢?
}
}