I loaded an html document in the Xdocument object :
XDocument xdoc = Xdocument.load(path);
XElement el = new XElement("name","value");
xdoc.Descendants("body").Single().Add(el); <=== sequence conatin no element
document contains the body element, then why this exception is coming ?
I suspect the problem is that it can’t find the
bodyelement due to namespacing. If it’s in a namespace, you can find it using: