I want to add an elements ,nodes to an existing Xml.
I am using the below mentioned Code ,but not getting proper output of Xml.
XmlNode root=doc.SelectSingleNode("DB");
XmlElement elem = doc.CreateElement("ScopeCleanUp");
root.AppendChild(elem);
XmlNode rootLoc= doc.SelectSingleNode("DBSync/ScopeCleanUp");
XmlElement elemLoc = doc.CreateElement("LocalScope");
XmlNode rootScope = doc.SelectSingleNode("DBSync/ScopeCleanUp/LocalScope");
for (int s = 0; s < 2; s++)
{
XmlElement elemScope = doc.CreateElement("ScopeName");
elemScope.InnerText = s.ToString();
rootLoc.AppendChild(elemScope);
}
rootLoc.AppendChild(elemLoc);
I need the Xml as below Output.
<DB>
<ScopeCleanUp>
<LocalDataBase>
<ScopeName>1</ScopeName>
<ScopeName>2</ScopeName>
</LocalDataBase>
</ScopeCleanUp>
</DB>
Something like this should do the trick: