In the below code I am getting error with the statement inside the for loop so here basically I am trying to get all the specific tag name I want and copy all of them into new xml document. Can anyone please help me out to resolve this issue
C#:
XmlDocument _xd = new XmlDocument();
_xd.Load(@"C:\rsr.xml");
XmlNodeList elemList = _xd.GetElementsByTagName("Prototype");
XmlDocument ifArxml = new XmlDocument();
XmlElement rootnode = ifArxml.CreateElement("TS");
XmlElement arpackgs = ifArxml.CreateElement("context");
XmlElement arpackg = ifArxml.CreateElement("name");
XmlElement snm = ifArxml.CreateElement("package");
XmlElement elem = ifArxml.CreateElement("elements");
ifArxml.AppendChild(rootnode);
rootnode.AppendChild(arpackgs);
arpackgs.AppendChild(arpackg);
arpackg.AppendChild(snm);
arpackg.AppendChild(elem);
for (int i = 0; i < elemList.Count; i++)
{
elem.AppendChild(elemList.OuterXml);
}
ifArxml.Save(@"C:\check.xml");
Last edited by a moderator: