0

我有一个简单的服务器 - 客户端架构。我想在客户端使用自定义 xml 和 javascript 创建 mxgraph。这是我的xml的结构:

<mycustomroot>
<!-- some not mxgraph related tags -->
<some-custom-tag>
 ......
</some-custom-tag>

<!-- this is standard mxgraph model-->
<mxGraphModel>
  ......
</mxGraphModel>

<!-- this is standard mxgraph stylesheet-->
<mxStylesheet>
  .....
</mxStylesheet>
</mycustomroot>

我的第一个问题是:如何从这个 xml 创建一个图表?(我不想编写自定义解析器,因为其中的所有内容都是标准 mxgraph。)我想做类似的事情:

dec.decode(node, graph.getModel());

(其中节点是 xml 中的 mxgraphmodel 标记。)

第二个问题是:我想使用图标,这些图标由服务器作为基于文本的字节数组发送。在 mxConstants 中,STYLE_IMAGE 描述并不是很有用。

提前感谢您的回答!

4

1 回答 1

0

你只需要解析你的文件吗?

parser = new DOMParser();
xmlDoc = parser.parseFromString(text,"text/xml");

使用文本将您收到的 xml 转换为字符串

于 2017-01-26T15:15:22.653 回答