How to load saved diagram in bpmn.io


#1

Hi,

I’m Using bpmn.io for my anuglar project i can able to save the output in xml, now i want to show/load the saved xml diagram to the editor back, i searched and found about viewer but i want some example to proceed further, any suggestions

Thanks,
Siva


#2

Hi @SIva

You want show output bpmn xml in div/textarea/…???


#3

Have you had a look at <input type=“file”>?


#4

can i use this particular method?

const url = 'myfilepath';
this.http.get(url, {
  headers: {observe: 'response'}, responseType: 'text'
}).subscribe(
  (x: any) => {
    console.log('Fetched XML, now importing: ', x);
    this.modeler.importXML(x, this.handleError);
  },
  this.handleError
);

thanks,
Siva


#5

Hi @SIva

I think if you get valid bpmn xml from server, yes, you can use this method, but maybe you need change importXML function to standard way like this :

this.modeler.importXML(xml, function (error) {
                if (error) {
                    return console.log('could not import bpmn diagram', error);
                }

                var canvas = modeler.get('canvas');

                canvas.zoom('fit-viewport');

                console.log('end open predesigned diagram');

                resolve(true);
            }); 

Good luck.


#6

Thanks for the suggestion @Hadi_Jami

i will try this for sure.