日期:2014-05-18 浏览次数:20960 次
- <props> <prop name="DocumentTypeDesc" type="10">Herry</prop> <prop name="client_data" type="10" /> <prop name="isInteract" type="3">false</prop> <prop name="max_versions" type="1">4</prop> <prop name="SSN" type="10">371248104</prop> - </props> - <props> <prop name="DocumentTypeDesc" type="10">Tansion</prop> <prop name="client_data" type="10" /> <prop name="isInteract" type="3">false</prop> <prop name="max_versions" type="1">4</prop> <prop name="SSN" type="10">158345561</prop> - </props>
XmlDocument document = new XmlDocument(); document.Load(@"D:\Collection.xml");//导入能成功 XmlNodeList nodes = document.GetElementsByTagName("prop"); foreach (XmlElement singlenode in nodes) { if(singlenode.GetAttributeNode("name").Value.ToString().Equals("SSN")) { Console.WriteLine("{0}",singlenode.Value); } }
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"c:\test.xml"); XmlNodeList nodes = xmlDoc.SelectNodes(@"//prop[@name='SSN']"); foreach (XmlNode node in nodes) Console.WriteLine(node.InnerText); Console.ReadKey();
------解决方案--------------------
singlenode.Value-->singlenode.InnerText