Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 01, 2012 12:18 PM by bharris17
May 31, 2012 07:05 PM|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 07:14 AM|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 12:18 PM|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.