GoJS 默认只支持读写 JSON 模型。如果您想读取和写入 XML,您需要使用常规 JavaScript 对象并实现您自己的与 XML 之间的持久性。
这里有一个从 XML 加载的非常简单的示例:http: //gojs.net/latest/samples/minimalXML.html
它确实:
// The previous initialization is the same as the minimal.html sample.
// Here we request XML-format text data from the server, in this case from a static file.
jQuery.ajax({
url: "minimal.xml",
success: load,
dataType: "xml"
});
}
function load(x) {
// ought to handle parse errors here:
var xml = jQuery(x.xml ? x.xml : x);
// this does direct binding to XML DOM elements:
myDiagram.model = new go.GraphLinksModel(xml.find("node").toArray(), xml.find("link").toArray());
// such binding is read-only at the current time
}