Last post Jun 01, 2012 01:18 PM by bharris17
May 31, 2012 08:05 PM|bharris17|LINK
I have an xml file that looks like the following and I want to add a parent node after the Insurer section and before the Broker - notice that in the Broker section, there will be multiple elements groupings.. The node in bold is what I want to add - no
elements needed just the two tags.
Jun 01, 2012 08:14 AM|FarhanK|LINK
Well, You can also use the code below to add the node.
XmlDocument objDOM = new XmlDocument();
XmlNodeList nodeList = objDOM.SelectNodes("BatchDataSet/Broker");
objDOM.SelectSingleNode("BatchDataSet").InsertAfter(objDOM.CreateNode(XmlNodeType.Element, null, "Brokers", string.Empty), objDOM.SelectSingleNode("BatchDataSet/Insurer"));
foreach (XmlNode n in nodeList)
Jun 01, 2012 01:18 PM|bharris17|LINK
Thank you very much! Just what I needed. Also, remember to add objDOM.save to save after this update. I wanted to add this in case someone else needs a solution like this.