解析XML文件

获取XML文件

        private XmlDocument GetDoc(string strpath)
        {
            if (System.IO.File.Exists(strpath) == true)
            {
                XmlDocument document = new XmlDocument();
                document.Load(strpath);//加载xml文档
                return document;
            }
            else
            {
                return null;
            }

        }

解析XML

XmlNode newNode = document.DocumentElement.SelectSingleNode("//layer[@name='" + 名称+ "']");
if (newNode != null)
{
  string aliasName = newNode.Attributes["别名"].Value.ToString();
  string strDes = newNode.Attributes["描述"].Value.ToString(); }

 

XmlNode SymbologyNode = NameNode.SelectSingleNode("//Symbology[@FieldValue='" + strieldValue + "']");

 

XmlNode SymbologyNode = NameNode.SelectSingleNode("//layer[@name='" + layerName + "']//Symbology[@FieldValue='" + strieldValue + "']");

 

posted @ 2016-05-27 13:42  恋上微笑的天使  阅读(188)  评论(0编辑  收藏  举报