Reputation: 321
I am trying to add as value to an XElement
mixed text and inline elements.
For example when setting the string "this is a mixed text <foo>and</foo> inline element."
the XElement.Nodes
to be able to return the text node as XmlNodeType.Text
& the element as XmlNodeType.Element
.
Thanks in advance.
Upvotes: 1
Views: 399
Reputation: 167726
Use e.g. new XElement("parent", "this is a mixed text ", new XElement("foo", "and"), " inline element.")
respectively element.Add("this is a mixed text ", new XElement("foo", "and"), " inline element.")
.
If you have a plain string then use e.g.
element.Add(XElement.Parse("<root>" + "this is a mixed text <foo>and</foo> inline element." + "</root>").Nodes());
Upvotes: 2