My xml is this:
<Settings>
<Ss></Ss>
<Properties>
<Property>
<Name>x</Name>
<Description>xx</Description>
</Property>
<Property>
<Name>y</Name>
<Description>yyyyy</Description>
</Property>
</Properties>
</Settings>
I want to add as a son of Properties an XElement. This is my code:
XDocument xmlDoc1 = XDocument.Load(@"C:\Users\John\Desktop\FileXml.xml");
xmlDoc1.Element("Properties").Add(new XElement(addManyNodes));
But it doesn't work. It throws null reference exception. Why?