Hey,
answering your two questions:
- That is what bpmn-js does when importing a BPMN diagram. You can simply retrieve your element from the element registry and access its business properties through its business object:
var modeler = new Modeler({
// ...
});
modeler.importXML(xml, function(err, warnings) {
var elementRegistry = modeler.get('elementRegistry');
var myElement = elementRegistry.get('myElement').businessObject;
// ...
});
- You can only export the entire diagram using
#saveXML
. However, you can use the element registry to get an elements SVG, too:
var myElementGraphics = elementRegistry.getGraphics('myElement');
// ...
You could use that as a starting point for building a saveElementSVG
functionality.
Hope that helps.