xml操作

loadxml

 

XmlDocemnt xmlDoc=new XmlDocument();

XmlDoc.LoadXml("路径");

XmlElement rootElement=xmlDoc.DocumentElement;

XmlNodeList dataList=rootElemnt.SelecteNodes("'/student/name");//节点下的路径

 

Hashtable hsXML = new Hashtable();

foreach(XmlNode xn in dataList)

{

         if (!hsXML.ContainsKey(xn.Attributes["FieldName"].Value.Trim()) && xn.Attributes["Value"] != null)
                    {
                        hsXML.Add(xn.Attributes["FieldName"].Value.Trim(), xn.Attributes["Value"].Value.Trim());
                    } 

}

 

posted on 2018-03-11 15:43  sxjljj  阅读(82)  评论(0编辑  收藏  举报