Reputation: 87
I want to get xml data from editor. http://jgraph.github.io/mxgraph/javascript/examples/grapheditor/www/index.html
Does anyone know how to get xml data from mxGraph editor by javascript ?
var Draw = new function __Draw() {
this.save = function () {
var graph = new Graph();
var encoder = new mxCodec();
var result = encoder.encode(graph.getModel());
var xml = encodeURIComponent(mxUtils.getXml(result));
// var xml = mxUtils.getXml(EditorUi.editor.getGraphXml());
console.log('xml');
console.log(xml);
AP.post("api/draw/server", {xml: xml}, function(code){
if (!code.good()){
return AP.alertError(code.message);
}
});
}
}
Upvotes: 1
Views: 1249
Reputation: 474
The commented code is the answer. editor.getGraphXml() should return the xml representation of the graph
var xml = mxUtils.getXml(EditorUi.editor.getGraphXml());
console.log('xml', xml);
Upvotes: 1