获取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 + "']");