tags:

views:

711

answers:

5
A: 

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
A: 

You may need to xml encode the names because '&' is a special character.

So instead of

XElement xe = new XElement("mo", "&InvisibleTimes");

try

XElement xe = new XElement("mo", "&InvisibleTimes");
Chris Brandsma
Marc Gravell
A: 

According to this thread, LINQ to XML doesn't include entity references: it doesn't have any node type for them. It just expands them as it loads a file, and after that you've just got "normal" characters.

Jon Skeet
A: 
dommer
A: 

As others have pointed out, there is no direct way to do it.

That said, you can try using the corresponding unicode caracther. According to http://www.w3.org/TR/MathML2/mmlalias.html, for ApplyFunction it is 02061, try new XElement("mo", "\u02061")

eglasius