python-mathdom的替代品

Mic*_*ert 6 python mathml

我想将MathML表达式转换为python中的方程字符串,MathDOM模块应该适用于该字符串.

一个例子是:

<math xmlns="http://www.w3.org/1998/Math/MathML">
   <lambda>
     <bvar><ci>A</ci></bvar>
     <bvar><ci>B</ci></bvar>
     <apply>
         <plus/>
         <ci>A</ci>
         <ci>B</ci>
     </apply>
   </lambda>
</math>
Run Code Online (Sandbox Code Playgroud)

应映射到"A + B".这显然适用于更复杂的表达式.

但是,它已经很老了,并且不能正常使用新版本的xml模块(试图包含错误的模块结构等)

有谁知道有用的替代品?

Mic*_*ert 2

迄今为止最好的解决方案:libsbml

from libsbml import *
ast = readMathMLFromString(xmlString)
f = FunctionDefinition(2,4)
f.setMath(ast)
kl = KineticLaw(2,4)
kl.setMath(f.getBody())
kl.getFormula()
Run Code Online (Sandbox Code Playgroud)

对我来说没问题,因为我已经在使用它了,但距离通用解决方案还很远。