R
RolfLi
Guest
The c# code below works but i think there is for sure a more efficient and elegant way to get the result
XDocument doc = XDocument.Load(file);
XElement elements = doc.Root;
var items = elements.Descendants("Product_Recipe_System");
var subitems = items.Descendants("Values");
var ssubitems = subitems.Descendants("V");
foreach (XElement el in ssubitems)
{
if (el.Attribute("Item").Value.Equals("RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022"))
Console.WriteLine(el.Attribute("Value"));
}
my xml file looks like this:
<VWSRecipeFile>
<Product_Recipe_System User="TPDer" Version="1.0" Description="" LastChange="43304.5995196412">
<Values>
<V Item="Item1Davor" Type="8" Value="Piston2" />
<V Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Type="8" Value="Piston2" />
<V Item="Itemdanach" Type="2" Value="10" />
</Values>
<Notes />
<Changes>
<_1 Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Date="43676.499687662" User="DefaultUser" OldValue="Piston1" NewValue="Piston2" />
<_2 Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Date="43682.3473187153" User="TPMechanic" OldValue="Piston2" NewValue="Piston1" />
<_3 Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Date="43682.3474320949" User="TPMechanic" OldValue="Piston1" NewValue="Piston2" />
</Changes>
</Product_Recipe_System>
<VWSRecipeFile>
Due to i'am new to linq i struggle to find the right query
Continue reading...
XDocument doc = XDocument.Load(file);
XElement elements = doc.Root;
var items = elements.Descendants("Product_Recipe_System");
var subitems = items.Descendants("Values");
var ssubitems = subitems.Descendants("V");
foreach (XElement el in ssubitems)
{
if (el.Attribute("Item").Value.Equals("RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022"))
Console.WriteLine(el.Attribute("Value"));
}
my xml file looks like this:
<VWSRecipeFile>
<Product_Recipe_System User="TPDer" Version="1.0" Description="" LastChange="43304.5995196412">
<Values>
<V Item="Item1Davor" Type="8" Value="Piston2" />
<V Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Type="8" Value="Piston2" />
<V Item="Itemdanach" Type="2" Value="10" />
</Values>
<Notes />
<Changes>
<_1 Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Date="43676.499687662" User="DefaultUser" OldValue="Piston1" NewValue="Piston2" />
<_2 Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Date="43682.3473187153" User="TPMechanic" OldValue="Piston2" NewValue="Piston1" />
<_3 Item="RecipeMgt.FileNames.Plg_DOSR022_V01_00Product_Recipe_DOSR022" Date="43682.3474320949" User="TPMechanic" OldValue="Piston1" NewValue="Piston2" />
</Changes>
</Product_Recipe_System>
<VWSRecipeFile>
Due to i'am new to linq i struggle to find the right query
Continue reading...