Search code examples
javascriptbpmnbpmn.io

how to export BPMN 2.0 xml format in bpmn.js


in bpmn.js I can import a file contain xml of BPMN 2.0 fromat like this :

var BpmnViewer = require('bpmn-js');

var xml; // my BPMN 2.0 xml
var viewer = new BpmnViewer({ container: 'body' });

viewer.importXML(xml, function(err) {

  if (err) {
    console.log('error rendering', err);
  } else {
    console.log('rendered');
  }
});

but I dont know how to export with xml format from bpmn project


Solution

  • answer by a.sh from http://forum.bpmn.io

    First Of All You should Use "modeler" insteaadiof "viewer". After that Use blow code

        modeler.saveXML({ format: true }, function (err, xml) {
            //here xml is the bpmn format 
        });