Read businessObjects from XML of a certain type without rendering

Hi there,

first of all I’d like to say that you have a very nice thing going here with! During my studies I worked a little with the Camunda engine and its webapps, now I’m working with bpmn-io/-js.

Unfortuneately, I am not well versed in JS or other web technologies, but I’m trying to get by with the documentation you have, forum posts and just tinkering.

I know how to access the underlying businessObject of a shape in the modeller / viewer (I’m using the bpmn-js seed). What I’d like to do though is the following:

  1. Read a BPMN file in XML format and parse it into some sort of elementRegistry.
  2. Access the elements like you would do in the renderer via the underlying businessObject of a shape, but without rendering anything / the shape.
  3. Then I would need to cycle through all elements to collect certain task types etc.

Is this possible, or do I have to go “the renderer way” to access an elementRegistry?
How can I get certain kinds of elements (i.e. tasks, user tasks,…) from the elementRegistry?

Best regards

bpmn-moddle is the library underneath bpmn-js that is responsible for XML parsing. It does not parse BPMN 2.0 into a shape and connection model but rather exposes the BPMN 2.0 meta-model directly.

As a result of parsing the BPMN 2.0 XML bpmn-moddle gives you access to all parsed IDs and the referenced objects, too. That means you can do something like this:

var BpmnModdle = require('bpmn-moddle');

var moddle = new BpmnModdle();

var xmlStr = '...';

var elementsById = {};

moddle.fromXML(xmlStr, function(err, definitions, context) {
  var id;

  // store ids + elements somewhere...
  for (id in context.elementsById) {
    elementsById[id] = context.elementsById[id];


I’d suggest you to dive a bit into the project and see if that suites your use case.

Thanks, I’ll give it a try.