// so i defined my own function
function execute(xml, graph, parent) {
let shapObjMap = new Map();
let linkObjMap = new Map();
let xmlDoc = mxUtils.parseXml(xml);
let childNs = xmlDoc.documentElement.childNodes[0].childNodes;
graph.getModel().beginUpdate();
try {
for (let i = 2; i < childNs.length; i++) {
let attrMap = childNs[i].attributes;
if (attrMap.getNamedItem('vertex') && attrMap.getNamedItem('vertex').value !== null) {
let attr = {
x: childNs[i].firstChild.getAttribute('x') && parseInt(childNs[i].firstChild.getAttribute('x')),
y: childNs[i].firstChild.getAttribute('y') && parseInt(childNs[i].firstChild.getAttribute('y')),
height: childNs[i].firstChild.getAttribute('height') && parseInt(childNs[i].firstChild.getAttribute('height')),
width: childNs[i].firstChild.getAttribute('width') && parseInt(childNs[i].firstChild.getAttribute('width')),
value: attrMap['value'] && attrMap['value'].value || '',
}
let obj = graph.insertVertex(parent, null, attr.value, attr.x, attr.y, attr.width, attr.height,attrMap.getNamedItem('style').value);
shapObjMap.set(attrMap['id'].value, obj);
}
if(attrMap.getNamedItem('edge') && attrMap.getNamedItem('edge').value !== null){
let attr = {
value: attrMap['value'] && attrMap['value'].value || '',
source: attrMap['source'] && attrMap['source'].value || null,
target: attrMap['target'] && attrMap['target'].value || null,
}
let obj = graph.insertEdge(parent, null, "",
shapObjMap.get(attr.source), shapObjMap.get(attr.target),
attrMap.getNamedItem("style").value); // you've forgotten to parse edge styles here
linkObjMap.set(attrMap['id'].value, obj);
}
}
} finally {
// Updates the display
graph.getModel().endUpdate();
}
}