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); }
public static int GetProvinceId(string ProvinceName) { string xpath = string.Format("//province[@name='{0}']", ProvinceName); XmlDocument regionDocument = RegionHelper.GetRegionDocument(); XmlNode xmlNode = regionDocument.SelectSingleNode(xpath); if (xmlNode != null && xmlNode.Attributes["id"] != null) { return(int.Parse(xmlNode.Attributes["id"].Value)); } return(0); }
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); }
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); if (xmlNode != null) { foreach (XmlNode xmlNode2 in xmlNode.ChildNodes) { dictionary.Add(int.Parse(xmlNode2.Attributes["id"].Value), xmlNode2.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); }