如何读取 xml 文件来绘制图形。
我下面的代码行用于获取这样的 XML 数据。我需要将所有 XML 数据放入var doc object
图表中以绘制形状
var doc = mxUtils.parseXml(STYLE_PATH+'/Test.xml');
完整代码如下:
mxUtils.getAll([bundle, STYLE_PATH + '/default.xml'], function (xhr) {
// Adds bundle text to resources
mxResources.parse(xhr[0].getText());
// Configures the default graph theme
var themes = new Object();
themes[Graph.prototype.defaultThemeName] = xhr[1].getDocumentElement();
// Main
new EditorUi(new Editor(urlParams['chrome'] == '0', themes));
var ui = new EditorUi(new Editor());
var doc = mxUtils.parseXml(STYLE_PATH+'/Test.xml');
ui.editor.setGraphXml(doc.documentElement);
},
function () {
document.body.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
});