Adding element to existing XML node

Posted by Sathish on Stack Overflow See other posts from Stack Overflow or by Sathish
Published on 2010-04-19T03:34:15Z Indexed on 2010/04/19 3:43 UTC
Read the original article Hit count: 244

Filed under:

Where am i going wrong???

I have an xml file with OppDetails as a tag already as shown below

<OppDetails>
  <OMID>245414</OMID> 
  <ClientName>Best Buy</ClientName> 
  <OppName>International Rate Card</OppName> 
  <CTALinkType>AO,IO,MC,TC</CTALinkType> 
  </OppDetails>
  </OppFact>

Now i am trying to add another element to it but getting an error in AppendChild method please help

XmlNode rootNode = xmlDoc.SelectSingleNode("OppDetails");
XmlElement xmlEle = xmlDoc.CreateElement("CTAStartDate");
xmlEle.InnerText = ExcelUtility.GetCTAStartDate();
rootNode.AppendChild(xmlEle);
            xmlDoc.Save("C:\\test.xml");

© Stack Overflow or respective owner

Related posts about c#