Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Code examples (Python)

ahankinson edited this page Mar 1, 2012 · 3 revisions

Some code examples to illustrate how to use the Libmei Python bindings:

Reading in an MEI XML file

from pymei import XmlImport

doc = XmlImport.documentFromFile("beethoven.mei")

Writing out an XML file

from pymei import MeiDocument, MeiElement, XmlExport

# create a very basic document structure
doc = MeiDocument()
root = MeiElement("mei")
root.id = "myid"
doc.root = root

note = MeiElement("note")
note.id = "noteid"
note.value = "value"
note.tail = "tail"
root.addChild(note)

# This will return True if it was successful
status = XmlExport.meiDocumentToFile('testdoc.mei')

You can also look at the Python unit tests code for more examples.

Clone this wiki locally