30 lines
906 B
C#
30 lines
906 B
C#
using System;
|
|
using System.Xml.Linq;
|
|
|
|
namespace vr21
|
|
{
|
|
class Program
|
|
{
|
|
private static string _xmllocation = @"..\..\..\XMLRecipe.xml";
|
|
static void Main(string[] args)
|
|
{
|
|
writeReceipesInformation();
|
|
Console.ReadKey();
|
|
}
|
|
|
|
static void writeReceipesInformation()
|
|
{
|
|
XDocument xdoc = XDocument.Load(_xmllocation);
|
|
var allReceipes = xdoc.Descendants("Recipe");
|
|
foreach (var receipe in allReceipes)
|
|
{
|
|
Console.WriteLine(receipe.Element("Name").Value);
|
|
foreach (var ingredient in receipe.Element("Ingredients").Elements())
|
|
{
|
|
Console.WriteLine($" {ingredient.Element("Name").Value}: {ingredient.Element("Amount").Value}{ingredient.Element("Unit").Value}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|