Best practice to populate XElement with some text that containes XML nodes inside

macvwin

New Member
what is the best way to populate XElement with the test that may contains not only the pure text but some XML nodes as well?For example, this code\[code\]XElement el = new XElement("XML_NODE");el.Value = "http://stackoverflow.com/questions/14482620/some text <TAG>with custom tag value</TAG>";string xml = el.ToString();\[/code\]will return xml as \[code\]<XML_NODE>some text <TAG>with custom tag value</TAG></XML_NODE>\[/code\]. I understand what is going on and why it has happened. But it's not exactly what I want... I wish to get xml similar to this \[code\]<XML_NODE>some text <TAG>with custom tag value</TAG></XML_NODE>\[/code\] where inner brackets are not quoted. The desired result can be achieved by the next code\[code\]XElement el2 = XElement.Parse("<XML_NODE>some text <TAG>with custom tag value</TAG></XML_NODE>");xml = el2.ToString();\[/code\]but I don't like the idea to build XML as a string and parse it later. Are there any other better ways to get it?
 
Back
Top