I have an element Name "Dispute" and want to add new element name "Records" below the element.
Eg: The current XML is in this format
<NonFuel>
<Desc>Non-Fuel</Desc>
<Description>
</Description>
<Quantity/>
<Amount/>
<Additional/>
<Dispute>0</Dispute>
</NonFuel>
Need to add new element under dispute.
<NonFuel>
<Desc>Non-Fuel</Desc>
<Description>
</Description>
<Quantity/>
<Amount/>
<Additional/>
<Dispute>0</Dispute>
<Records>01920</Records>
</NonFuel>
Updated Code:
Tried doing the following Code but getting error "The reference node is not child of this node":
XmlDocument xmlDoc=new XmlDocument()
xmlDoc.LoadXml(recordDetails);
XmlNodeList disputes = xmlDoc.GetElementsByTagName(disputeTagName);
XmlNode root = xmlDoc.DocumentElement;
foreach (XmlNode disputeTag in disputes)
{
XmlElement xmlRecordNo = xmlDoc.CreateElement("RecordNo");
xmlRecordNo.InnerText = Guid.NewGuid().ToString();
root.InsertAfter(xmlRecordNo, disputeTag);
}