MCPcopy
hub / github.com/apache/echarts / parse

Function parse

extension-src/dataTool/gexf.ts:30–61  ·  view source on GitHub ↗
(xml)

Source from the content-addressed store, hash-verified

28import * as zrUtil from 'zrender/src/core/util';
29
30export function parse(xml) {
31 let doc;
32 if (typeof xml === 'string') {
33 const parser = new DOMParser();
34 doc = parser.parseFromString(xml, 'text/xml');
35 }
36 else {
37 doc = xml;
38 }
39 if (!doc || doc.getElementsByTagName('parsererror').length) {
40 return null;
41 }
42
43 const gexfRoot = getChildByTagName(doc, 'gexf');
44
45 if (!gexfRoot) {
46 return null;
47 }
48
49 const graphRoot = getChildByTagName(gexfRoot, 'graph');
50
51 const attributes = parseAttributes(getChildByTagName(graphRoot, 'attributes'));
52 const attributesMap = {};
53 for (let i = 0; i < attributes.length; i++) {
54 attributesMap[attributes[i].id] = attributes[i];
55 }
56
57 return {
58 nodes: parseNodes(getChildByTagName(graphRoot, 'nodes'), attributesMap),
59 links: parseEdges(getChildByTagName(graphRoot, 'edges'))
60 };
61}
62
63function parseAttributes(parent) {
64 return parent ? zrUtil.map(getChildrenByTagName(parent, 'attribute'), function (attribDom) {

Callers 1

renderInnerMethod · 0.85

Calls 4

getChildByTagNameFunction · 0.85
parseAttributesFunction · 0.85
parseNodesFunction · 0.85
parseEdgesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…