2017-02-01 16:06:52 +02:00
|
|
|
|
using System;
|
2017-02-01 17:21:58 +02:00
|
|
|
|
using System.Xml.Linq;
|
2017-02-01 16:06:52 +02:00
|
|
|
|
|
|
|
|
|
namespace vr21
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2017-02-01 17:21:58 +02:00
|
|
|
|
private static string _xmllocation = @"..\..\..\XMLRecipe.xml";
|
2017-02-01 16:06:52 +02:00
|
|
|
|
static void Main(string[] args)
|
2017-02-01 17:21:58 +02:00
|
|
|
|
{
|
|
|
|
|
writeReceipesInformation();
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
2017-02-01 17:03:44 +02:00
|
|
|
|
|
2017-02-01 17:21:58 +02:00
|
|
|
|
static void writeReceipesInformation()
|
|
|
|
|
{
|
|
|
|
|
XDocument xdoc = XDocument.Load(_xmllocation);
|
|
|
|
|
var allReceipes = xdoc.Descendants("Recipe");
|
|
|
|
|
foreach (var receipe in allReceipes)
|
2017-02-01 17:03:44 +02:00
|
|
|
|
{
|
2017-02-01 17:21:58 +02:00
|
|
|
|
Console.WriteLine(receipe.Element("Name").Value);
|
|
|
|
|
foreach (var ingredient in receipe.Element("Ingredients").Elements())
|
2017-02-01 17:03:44 +02:00
|
|
|
|
{
|
2017-02-01 17:21:58 +02:00
|
|
|
|
Console.WriteLine($" {ingredient.Element("Name").Value}: {ingredient.Element("Amount").Value}{ingredient.Element("Unit").Value}");
|
2017-02-01 17:03:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-01 16:06:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|