public static System.Collections.Generic.Dictionary <int, string> GetAllCitys() { System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNode xmlNode = regionDocument.SelectSingleNode("root"); foreach (XmlNode xmlNode2 in xmlNode.ChildNodes) { if (xmlNode2.ChildNodes.Count > 0) { foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes) { string value = xmlNode3.Attributes["name"].Value; if (xmlNode3.ChildNodes.Count > 0) { foreach (XmlNode xmlNode4 in xmlNode3.ChildNodes) { dictionary.Add(int.Parse(xmlNode4.Attributes["id"].Value), value + "-" + xmlNode4.Attributes["name"].Value); } } } } } return(dictionary); }
public static int GetRegionId(string county, string city, string province) { string xpath = string.Format("//province[@name='{0}']", province); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNode xmlNode = regionDocument.SelectSingleNode(xpath); int result; if (xmlNode != null) { int num = int.Parse(xmlNode.Attributes["id"].Value); xpath = string.Format("//province[@id='{0}']/city[@name='{1}']", num, city); xmlNode = xmlNode.SelectSingleNode(xpath); if (xmlNode != null) { num = int.Parse(xmlNode.Attributes["id"].Value); xpath = string.Format("//city[@id='{0}']/county[@name='{1}']", num, county); xmlNode = xmlNode.SelectSingleNode(xpath); if (xmlNode != null) { num = int.Parse(xmlNode.Attributes["id"].Value); } } result = num; } else { result = 0; } return(result); }
private static System.Collections.Generic.Dictionary <int, string> GetChildList(string xpath) { System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNode xmlNode = regionDocument.SelectSingleNode(xpath); foreach (XmlNode xmlNode2 in xmlNode.ChildNodes) { dictionary.Add(int.Parse(xmlNode2.Attributes["id"].Value), xmlNode2.Attributes["name"].Value); } return(dictionary); }
public static System.Collections.Generic.Dictionary <int, string> GetAllProvinces() { System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNodeList xmlNodeList = regionDocument.SelectNodes("//province"); foreach (XmlNode xmlNode in xmlNodeList) { dictionary.Add(int.Parse(xmlNode.Attributes["id"].Value), xmlNode.Attributes["name"].Value); } return(dictionary); }
public static System.Collections.Generic.Dictionary <int, string> GetAllRegionIds(bool readRegion, bool readprovince, bool readcity, bool readcounty) { System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNode xmlNode = regionDocument.SelectSingleNode("root"); foreach (XmlNode xmlNode2 in xmlNode.ChildNodes) { if (readRegion) { dictionary.Add(int.Parse(xmlNode2.Attributes["id"].Value), xmlNode2.Attributes["name"].Value); } if (xmlNode2.ChildNodes.Count > 0) { foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes) { if (readprovince) { dictionary.Add(int.Parse(xmlNode3.Attributes["id"].Value), xmlNode3.Attributes["name"].Value); } if (xmlNode3.ChildNodes.Count > 0) { foreach (XmlNode xmlNode4 in xmlNode3.ChildNodes) { if (readcity) { dictionary.Add(int.Parse(xmlNode4.Attributes["id"].Value), xmlNode4.Attributes["name"].Value); } if (xmlNode4.ChildNodes.Count > 0) { foreach (XmlNode xmlNode5 in xmlNode4.ChildNodes) { if (readcounty) { dictionary.Add(int.Parse(xmlNode5.Attributes["id"].Value), xmlNode5.Attributes["name"].Value); } } } } } } } } return(dictionary); }
private static XmlNode FindNode(int id) { string arg = id.ToString(System.Globalization.CultureInfo.InvariantCulture); string xpath = string.Format("//county[@id='{0}']", arg); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNode xmlNode = regionDocument.SelectSingleNode(xpath); XmlNode result; if (xmlNode != null) { result = xmlNode; } else { xpath = string.Format("//city[@id='{0}']", arg); xmlNode = regionDocument.SelectSingleNode(xpath); if (xmlNode != null) { result = xmlNode; } else { xpath = string.Format("//province[@id='{0}']", arg); xmlNode = regionDocument.SelectSingleNode(xpath); if (xmlNode != null) { result = xmlNode; } else { result = null; } } } return(result); }