Adding XML attribute to an element

Protos

New Member
Looking to add an attribute to an existing xml element \[code\]<D_COMMS>\[/code\], not replace the existing attribute just add it to the beginning.This is the XML\[code\]<OUTPUT version="2.0"> <RESPONSE> <DATA id="17fb13cca6c5463597fdf340c044069f"> <![CDATA[<ID> jdfkldklfjdkl</ID><D_COMMS>ON this date...</D_COMMS>]]> </DATA> </RESPONSE>\[/code\]This XML is the result of a HTTPWebResponse so this is what the XMl looks like when it comes back to me and I need to add a value to the D_COMMS element and send it back.Tried something like this to look for the descendant DATA and add it that way.\[code\]var addelement = doc.Descendants("DATA").First();addelement.Add(XElement("D_COMMS","On this date we said"));\[/code\]
 
Back
Top