XML Functions

Although Myokit’s mmt format is not an XML format, Myokit interacts with XML formats in various ways. The myokit.mxml module provides XML tools for common tasks. This module is imported as part of the main myokit package.

myokit.mxml.write_mathml(expression, presentation)

Converts a myokit Expression to a mathml expression.

The boolean argument presentation can be used to select between Presentation MathML and Content MathML.

Dom traversal

myokit.mxml.dom_child(node, selector=None)

Returns the first child element of the given DOM node.

If the optional selector is given it searches for an element of a particular type.

Returns None if no such node is found.

myokit.mxml.dom_next(node, selector=False)

Returns the next sibling element after the given DOM node.

If the optional selector is given it searches for an element of a particular type.

Returns None if no such node is found.

Converting html to ascii

myokit.mxml.html2ascii(html, width=79, indent=' ')

Flattens HTML and attempts to create readable ASCII code.

The output will be text-wrapped after width characters. Each new level of nesting will be indented with the text given as indent.