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.

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.

Etree helpers

myokit.mxml.split(tag)

Splits a tag (as used in elementtree) into a namespace and an element name part.

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.