示例#1
0
        private XmlNode SetCategoryFormatting(XmlDocument xmlmenu, FoodItemInfo item)
        {
            XmlNode      categoryNode      = xmlmenu.CreateElement("MenuCategory");
            XmlAttribute categoryAttribute = xmlmenu.CreateAttribute("category");

            categoryAttribute.Value = item.category.ToUpper();
            categoryNode.Attributes.Append(categoryAttribute);
            xmlmenu.DocumentElement.AppendChild(categoryNode);

            return(categoryNode);
        }
 private void SetCategoryFormatting( FormattedFoodItemInfo formattedItem, FoodItemInfo item)
 {
     formattedItem.category_beforeFormat = "UPPER";
     formattedItem.category = item.category.ToUpper();
 }
        private XmlNode SetCategoryFormatting(XmlDocument xmlmenu, FoodItemInfo item)
        {
            XmlNode categoryNode = xmlmenu.CreateElement("MenuCategory");
            XmlAttribute categoryAttribute = xmlmenu.CreateAttribute("category");
            categoryAttribute.Value = item.category.ToUpper();
            categoryNode.Attributes.Append(categoryAttribute);
            xmlmenu.DocumentElement.AppendChild(categoryNode);

            return categoryNode;
        }
示例#4
0
        public override List <FoodItemInfo> readFile2(string file, string country)
        {
            var         returnDict = new Dictionary <string, string>();
            XmlDocument xmldoc     = new XmlDocument();

            xmldoc.LoadXml(file);

            FoodItemDataList resultList = new FoodItemDataList();

            resultList.foodItems = new List <FoodItemInfo>();

            XmlNodeList fooditemList;

            if (country == "British")
            {
                fooditemList = xmldoc.SelectNodes("FoodItemData/FoodItem[@country='GB']");
            }
            else
            {
                fooditemList = xmldoc.SelectNodes("FoodItemData/FoodItem[@country='US']");
            }

            foreach (XmlNode foodItem in fooditemList)
            {
                if (foodItem.HasChildNodes)
                {
                    var item = new FoodItemInfo();
                    foreach (XmlNode foodinfo in foodItem)
                    {
                        if (foodinfo.Name == "country")
                        {
                            item.country = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "category")
                        {
                            item.category = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "name")
                        {
                            item.name = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "price")
                        {
                            item.price = foodinfo.InnerText;
                        }


                        if (foodinfo.Name == "description")
                        {
                            item.description = foodinfo.InnerText;
                        }
                    }

                    resultList.foodItems.Add(item);
                }
            }

            return(resultList.foodItems);
        }
示例#5
0
 private void SetCategoryFormatting(FormattedFoodItemInfo formattedItem, FoodItemInfo item)
 {
     formattedItem.category_beforeFormat = "UPPER";
     formattedItem.category = item.category.ToUpper();
 }
        public override List<FoodItemInfo> readFile2(string file, string country)
        {
            var returnDict = new Dictionary<string, string>();
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(file);

            FoodItemDataList resultList = new FoodItemDataList();
            resultList.foodItems = new List<FoodItemInfo>();

            XmlNodeList fooditemList;

            if (country == "British")
            {
                fooditemList = xmldoc.SelectNodes("FoodItemData/FoodItem[@country='GB']");
            }
            else
            {
                fooditemList = xmldoc.SelectNodes("FoodItemData/FoodItem[@country='US']");
            }

            foreach (XmlNode foodItem in fooditemList)
            {
                if (foodItem.HasChildNodes)
                {
                    var item = new FoodItemInfo();
                    foreach (XmlNode foodinfo in foodItem)
                    {
                        if (foodinfo.Name == "country")
                        {
                            item.country = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "category")
                        {
                            item.category = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "name")
                        {
                            item.name = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "price")
                        {
                            item.price = foodinfo.InnerText;
                        }

                        if (foodinfo.Name == "description")
                        {
                            item.description = foodinfo.InnerText;
                        }

                    }

                    resultList.foodItems.Add(item);
                }
            }

            return resultList.foodItems;
        }