private void Xml_Process_Button_Click(object sender, RoutedEventArgs e) { double sumTotalPrice = 0; double sumTotalPriceWithQuantity = 0; int counterItems = 0; double priceAverageValue = 0; var xmlData = XmlProcessor.LoadXml(pathOfXmlFileTextBlock.Text); foreach (var item in xmlData.Items) { foreach (var i in item.Item) { sumTotalPrice = sumTotalPrice + Convert.ToDouble(i.Price.Replace(".", ",")); sumTotalPriceWithQuantity = sumTotalPriceWithQuantity + Convert.ToDouble(i.Price.Replace(".", ",")) * Convert.ToInt16(i.Quantity); counterItems++; } } priceAverageValue = sumTotalPrice / counterItems; displayValues(xmlData.Id.ToString(), xmlData.Customer, convertDate(xmlData.Date), convertDoubleToSeparatedDouble(priceAverageValue), convertDoubleToSeparatedDouble(sumTotalPriceWithQuantity)); }