为什么取不到xmlnode 的值??
<User>
<Name> zhangsan </Name>
<City> shanghai </City>
<Email> zhangsna@322.net </Email>
<Message> sss </Message>
</User>
<User>
<Name> sss </Name>
<City> ss </City>
<Email> ss@22.net </Email>
<Message> asfdasfd </Message>
</User>
XmlDocument oXml = new XmlDocument();
XmlNodeList oNodes;
XmlNode oNode;
oXml.Load( "DataSet.xml ");
oNodes = oXml.DocumentElement.SelectNodes( "//User ");
for (int i = 0; i < oNodes.Count; i++)
{
oNode = oNodes[i];
MessageBox.Show( oNode.SelectSingleNode( "//Name ").InnerText;
}
为何每次取到的值都一样的???
------解决方案--------------------try
oNodes= oXml .SelectNodes( "User ");
foreach (XmlNode node in oNodes)
{
MessageBox.Show( node.SelectSingleNode( "Name ").InnerText;
}
------解决方案-------------------- <Users>
<User>
<Name> zhangsan </Name>
<City> shanghai </City>
<Email> zhangsna@322.net </Email>
<Message> sss </Message>
</User>
<User>
<Name> sss </Name>
<City> ss </City>
<Email> ss@22.net </Email>
<Message> asfdasfd </Message>
</User>
</Users>