I do have following xml:
<Assembly>
<Bench>
<Typ>P1</Typ>
<DUT>
<A>6</A>
</DUT>
</Bench>
<Bench>
<Typ>P2</Typ>
<DUT>
<A>6</A>
</DUT>
</Bench>
</Assembly>
How can I get a reference to 'P2'-element that I can insert a new DUT? I tried following code which gives me an error:
var xElement = xmlDoc.Element("Assembly")
.Elements("Bench")
.Where(item => item.Attribute("Typ").Value == "P2")
.FirstOrDefault();
xElement.AddAfterSelf(new XElement("DUT"));
thanks in advance