日期:2014-05-18 浏览次数:20833 次
string test = @"<?xml version='1.0' encoding='ISO-8859-1'?><UP><test><AID>123456</AID><BID>1</BID><C>02</C><D>2012-03-14</D><E>张三</E><BZ>测试</BZ></test></UP>"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(test); XmlNodeList xnl = xmlDoc.SelectNodes("UP/test"); foreach (XmlNode linkNode in xnl) { XmlElement xe = (XmlElement)linkNode;//将子节点类型转换为XmlElement类型 string AID = xe.SelectSingleNode("AID").InnerText.Trim(); string BID = xe.SelectSingleNode("BID").InnerText.Trim(); string C = xe.SelectSingleNode("C").InnerText.Trim(); string D = xe.SelectSingleNode("D").InnerText.Trim(); string E = xe.SelectSingleNode("E").InnerText.Trim(); string BZ = xe.SelectSingleNode("BZ").InnerText.Trim(); //inser into aa(a,v,v,v,v,v)values(); }