API to traverse diagram's BPMN elements

Hi

Is there an API to query and retrieve BPMN elements out of the loaded diagram? Perhaps something like jQuery’s $(“task[name=t1]”), or through xPath? I would like to read and extract some of the rendered BPMN in my own application but I’m not sure if I need to re-parse the XML or can I use the already parsed one?

The structure of rendered elements does not exactly match a BPMN 2.0 document. Depending on your use case it would be more appropriate to walk the BPMN tree.

var bpmnjs = new BpmnJS(...);

bpmnjs.importXML(someXML, function() {
  console.log(bpmnjs.definitions); // bpmn tree
});