I am trying to load xml into mxGraph but it doesn't seem to work. First i grab xml made in editor like this:
var encoder = new mxCodec();
var node = encoder.encode(graph.getModel());
var xml = mxUtils.getXml(node);
return xml;
After this function, this is a example xml i got:
<mxGraphModel><root><mxCell id="0"><mxCell id="1" parent="0"><mxCell id="2" value="TEST" xss=removed vertex="1" parent="1"><mxGeometry x="30" y="60" width="390" height="210" as="geometry"></mxCell><mxCell id="3" value="test 2" xss=removed vertex="1" parent="1"><mxGeometry x="550" y="110" width="440" height="130" as="geometry"></mxCell><mxCell id="4" edge="1" parent="1" source="2" target="3"><mxGeometry relative="1" as="geometry"></mxCell></root></mxGraphModel>
Then i try to load xml in a diffrent page with this code:
function loadGraphFromXML(xmlString){
var doc = mxUtils.parseXml(xmlString);
var codec = new mxCodec(doc);
codec.decode(doc.documentElement, graph.getModel());
}
This is the error i got.
mxObjectCodec.js:801 Uncaught TypeError: this.decodeChildren is not a function
at mxObjectCodec.decodeNode (mxObjectCodec.js:801:8)
at mxObjectCodec.decode (mxObjectCodec.js:780:7)
at mxCodec.decode (mxCodec.js:440:14)
at loadGraphFromXML (graph.js?v=1708919730:342:9)
at Object.success (graph.js?v=1708919730:372:5)
at i (jquery-3.1.1.min.js:2:27983)
at Object.fireWith [as resolveWith] (jquery-3.1.1.min.js:2:28749)
at A (jquery-3.1.1.min.js:4:14203)
at XMLHttpRequest.<anonymous> (jquery-3.1.1.min.js:4:16491)
Thanks
I tried converting to svg, didn't work. Tried diffrent xml types almost none of them did work.