Reputation: 9687
I get a "Object not set to an...." when I try to do this. The exceptions hits me on the last line.
xml.Add(new XElement("Root", ""));
xml.Element("Root").Add(new XElement("Sites", ""));
xmlContent = xmlContent.Element("Root").Element("Sites");
Anyone ?
Upvotes: 0
Views: 197
Reputation: 9687
The solution:
From:
xml.Add(new XElement("Root", ""));
xml.Element("Root").Add(new XElement("Sites", ""));
xmlContent = xmlContent.Element("Root").Element("Sites");
To:
xml.Add(new XElement("Root", ""));
xml.Element("Root").Add(new XElement("Sites", ""));
xmlContent = xml.Element("Root").Element("Sites");
I just needed to use the correct instance, xml and not xmlContent.
Thanks!
Upvotes: 0
Reputation: 174457
xmlContent
is null
or xmlElement
doesn't contain an element named Root
. That's all I can say from that little code.
Upvotes: 2