Linq to Xml和自定义xml实体 [英] Linq to Xml and custom xml entities

查看:62
本文介绍了Linq to Xml和自定义xml实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Linq to xml从表达式树创建MathML文档,但是我不知道如何使用MathML xml实体(例如⁡和& InvisibleTimes): 当我尝试使用直接创建XElement时

I want to create a MathML document from an expression tree using Linq to xml, but I cannot figure out how to use the MathML xml entities (such as ⁡ and &InvisibleTimes): When I try to create directly a XElement using

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

它只是逃离&符(这是不好的). 我也尝试使用XElement.Parse

it justs escapes the ampersand (which is no good). I also tried to use XElement.Parse

XElement xe = new XElement.Parse("<mo>&InvisibleTimes</mo>");

,但是它失败,并出现System.XmlException:对未声明的实体"InvisibleTimes"的引用 如何声明实体或忽略检查?

but it fails with an System.XmlException: Reference to undeclared entity 'InvisibleTimes' How can I declare the entity or ignore the checks?

推荐答案

正如其他人指出的那样,没有直接的方法可以做到这一点.

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

也就是说,您可以尝试使用相应的unicode caracther.根据 http://www.w3.org/TR/MathML2/mmlalias.html ,对于ApplyFunction为02061,请尝试新的XElement("mo","\ u02061")

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")

这篇关于Linq to Xml和自定义xml实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆