What would be the best option to read and add Xml element into existing source XML.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
What would be the best option to read and add Xml element into existing source XML. This source XML is available in string format in memory. should i use XDocument, XmlTextWriter.?? also should i use XLinq to evaluate the path or XPath? i read that
XPath is slower.<br/>
Ill have the XPath and its value information in Dictionary<string,string>. e.g Key = "Root/Data/PersonalInfo/FirstName", Value = "James"
<br/>
Here is the requitrement
if source XML has the path "Root/Data/PersonalInfo/FirstName"<br/>
then just assign "James" to the FirstName element<br/>
else<br/>
create the elemet at that path and assign the value.<br/>
(Note:it is possible that even parent element "Data" or "PersonalInfo" may not exists. so the logic should create that path

View the full article
 
Back
Top