I don't know about XDocument
, but you can do it with XmlDocument
:
XmlDocument doc = new XmlDocument();
var entity = doc.CreateEntityReference("InvisibleTimes");
XmlElement root = (XmlElement)doc.AppendChild(doc.CreateElement("xml"));
var el = root.AppendChild(doc.CreateElement("mo")).AppendChild(entity);
string s = doc.OuterXml;
Marc Gravell
2009-04-01 20:00:37