private void LoadXmlThesaban(XmlNode node) { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "entity") { _thesaban.Add(PopulationDataEntry.Load(childNode)); } } }
protected void DoLoad(XmlNode node) { if (node.Name == "entity") { _changwat = PopulationDataEntry.Load(node); } else if (node.Name == "thesaban") { LoadXmlThesaban(node); } }
static public List <PopulationDataEntry> GetRegionBySchemeName(String schemeName) { XElement regionsXml = XElement.Load(BasicRegionFileName()); List <PopulationDataEntry> result = new List <PopulationDataEntry>(); var query = from c in regionsXml.Descendants(TambonHelper.TambonNameSpace + "regions") where (string)c.Attribute("english") == schemeName select c.Elements(); foreach (var entry in query) { foreach (XElement lNode in entry) { PopulationDataEntry data = PopulationDataEntry.Load(XNodeToXmlNode(lNode)); result.Add(data); } } return(result); }
static public List <PopulationDataEntry> GetRegionBySchemeName(String iSchemeName) { XElement lRegionsXML = XElement.Load(BasicRegionFileName()); List <PopulationDataEntry> lResult = new List <PopulationDataEntry>(); var lQuery = from c in lRegionsXML.Descendants(TambonHelper.TambonNameSpace + "regions") where (string)c.Attribute("english") == iSchemeName select c.Elements(); foreach (var lEntry in lQuery) { foreach (XElement lNode in lEntry) { PopulationDataEntry lData = PopulationDataEntry.Load(XNodeToXmlNode(lNode)); lResult.Add(lData); } } return(lResult); }
internal static PopulationDataEntry Load(XmlNode iNode) { PopulationDataEntry RetVal = null; if (iNode != null && iNode.Name.Equals("entity")) { RetVal = new PopulationDataEntry(); RetVal.Name = TambonHelper.GetAttributeOptionalString(iNode, "name").Trim(); RetVal.English = TambonHelper.GetAttributeOptionalString(iNode, "english").Trim(); RetVal.Total = TambonHelper.GetAttributeOptionalInt(iNode, "total", 0); RetVal.Obsolete = TambonHelper.GetAttributeOptionalBool(iNode, "obsolete", false); RetVal.Male = TambonHelper.GetAttributeOptionalInt(iNode, "male", 0); RetVal.Female = TambonHelper.GetAttributeOptionalInt(iNode, "female", 0); RetVal.Households = TambonHelper.GetAttributeOptionalInt(iNode, "households", 0); RetVal.Geocode = TambonHelper.GetAttributeOptionalInt(iNode, "geocode", 0); RetVal.GeocodeOfCorrespondingTambon = TambonHelper.GetAttributeOptionalInt(iNode, "tambon", 0); RetVal.Comment = TambonHelper.GetAttributeOptionalString(iNode, "comment"); string lNewGeocode = TambonHelper.GetAttributeOptionalString(iNode, "newgeocode"); foreach (string lSubString in lNewGeocode.Split(new Char[] { ' ' })) { if (!string.IsNullOrEmpty(lSubString)) { RetVal.NewGeocode.Add(Convert.ToInt32(lSubString)); } } string s = TambonHelper.GetAttributeOptionalString(iNode, "type"); if (!String.IsNullOrEmpty(s)) { RetVal.Type = (EntityType)Enum.Parse(typeof(EntityType), s); } string lGeocodeParent = TambonHelper.GetAttributeOptionalString(iNode, "parent"); foreach (string lSubString in lGeocodeParent.Split(new Char[] { ' ' })) { if (!string.IsNullOrEmpty(lSubString)) { RetVal.GeocodeParent.Add(Convert.ToInt32(lSubString)); } } if (iNode.HasChildNodes) { foreach (XmlNode lChildNode in iNode.ChildNodes) { if (lChildNode.Name == "office") { EntityOffice lOffice = EntityOffice.Load(lChildNode); RetVal.Offices.Add(lOffice); } if (lChildNode.Name == "history") { RetVal.ParseHistory(lChildNode); } if (lChildNode.Name == "entity") { RetVal.SubEntities.Add(PopulationDataEntry.Load(lChildNode)); } if (lChildNode.Name == "constituencies") { RetVal.ConstituencyList.ReadFromXml(lChildNode); } } } } return(RetVal); }