Could not parse document, Error: missing start tag


#1

I’m trying the following example: https://github.com/bpmn-io/bpmn-js-examples/tree/master/simple-bower
But can’t get the example to run. I tested with different bpmn xmls but keep on getting the same error: Could not parse document, Error: missing start tag
What am I missing?

https://jsfiddle.net/gL73vpyd/16/


#2

Inspect the log with your browsers developer tools (F12). Your request to load the diagram fails with a Cross-Origin error.

The content for these responses is empty (''), that’s why you see the error Error: missing start tag.


#3

I did come across the Cross-Origin error when I was using:
xhr.open(‘GET’, ‘https://demo.bpmn.io/bpmn/diagrams/pizza-collaboration.bpmn’, true);
and looked in to CORS for the same.

But I also tried saving the bpmn(used different bpmns as well) locally and tested it with:

   viewer.importXML("diagram.bpmn", function(err) {
      if (!err) {
        viewer.get('canvas').zoom('fit-viewport');
      } else {
        console.log('something went wrong:', err);
      }
    });

Also tried:

   viewer.importXML("./diagram.bpmn", function(err) {...} // note the ./

With the same error, but without the Cross-Origin error.


#4

Exactly, because you’d need to pass the contents, not the file name to Viewer#importXML.

This should work in a sense that it gives you a different error mesage:

viewer.importXML('<foo />');