Skip to content
Moop204 edited this page Mar 10, 2021 · 1 revision

Guides

How to do things.

File to CellML Model

With Existing File Make a Parser object and give it the contents of a CellML file as a string. Run .parseModel() with the argument being the content of the file. \

const fs = require('fs'); 

const parser = new libcellml.Parser();
const file = fs.readFileSync('src/file', 'utf8');
const model =  parser.parseModel(file);

From Scratch [idk]

CellML Model to File

Make a Printer object and give it a model.

const printer = new libcellml.Printer();
const newContent = printer.printModel(model);
fs.writeFile("newFile.xml", newContent, (err) => {
  if(err) console.log("Failed to write to file");
  else console.log("Successfully wrote to file");
}
Clone this wiki locally