Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mxGraph: loading XML file

Tags:

xml

mxgraph

I'm new to mxGraph. Does anyone know how to save a file to my local storage from mxGraph editor (http://jgraph.github.io/mxgraph/javascript/examples/grapheditor/www/index.html)? BTW, are XML files created with draw.io compatible with mxGraph? Thanks.

like image 431
Jopa Avatar asked Aug 27 '26 22:08

Jopa


1 Answers

Use Codec and Encoder.

var encoder = new mxCodec();
var node = encoder.encode(graph.getModel()); 

variable node will have XML of your graph.

Use mxGraph utility to instantly show XML in popup.

mxUtils.popup(mxUtils.getPrettyXml(node), true);
like image 152
Shaybi Avatar answered Aug 29 '26 10:08

Shaybi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!