XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<zf:Company xmlns:zf="http://zhfsoft.com">
<zf:Employee>Chen</zf:Employee>
<zf:Employee>Leung</zf:Employee>
</zf:Company>
代码:
XmlDocument doc = new XmlDocument();
doc.Load("..\\..\\XF.xml");
XmlNamespaceManager namespacem = new XmlNamespaceManager(doc.NameTable);
namespacem.AddNamespace("prefix", "http://zhfsoft.com");
XmlElement element = doc.DocumentElement;
XmlNodeList node = element.SelectNodes("prefix:Employee", namespacem);
foreach (XmlNode item in node)
{
string nn = item.ChildNodes.Count.ToString();
}