There is xml, it needs to be processed, and understand which block is interconnected and present in an adequate form

<mxGraphModel dx="1434" dy="953" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" background="#ffffff"> <root> <mxCell id="0"/> <mxCell id="1" parent="0"/> <mxCell id="4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=1;exitY=0.5;entryX=0;entryY=0.5;jettySize=auto;orthogonalLoop=1;" edge="1" parent="1" source="2" target="3"> <mxGeometry relative="1" as="geometry"/> </mxCell> <mxCell id="2" value="A" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxGeometry x="100" y="60" width="120" height="100" as="geometry"/> </mxCell> <mxCell id="3" value="B" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxGeometry x="380" y="55" width="110" height="110" as="geometry"/> </mxCell> <mxCell id="5" value="C" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxGeometry x="100" y="290" width="120" height="60" as="geometry"/> </mxCell> <mxCell id="7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0;exitY=0.5;entryX=1;entryY=0.633;entryPerimeter=0;jettySize=auto;orthogonalLoop=1;" edge="1" parent="1" source="6" target="5"> <mxGeometry relative="1" as="geometry"/> </mxCell> <mxCell id="6" value="D" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxGeometry x="400" y="300" width="120" height="60" as="geometry"/> </mxCell> </root> </mxGraphModel> 

All this is drawn on draw.io (as this xml looks like on canvas) enter image description here

  • I understand the attributes, source = "2" target = "3", it goes from id 2 to id 3. But how can you parse the whole thing and convert it to the same JSON? - splincode
  • To vskidku, you have XML explicitly sets 6 objects. 4 - rectangles, they have the value attribute and what they do not know about with whom they are connected. 2 - connecting lines, with the attributes source and target , who know with whom they are connected. Try searching for such connecting lines and from them pull out information and connections between objects. Well, give an example. What do you mean to представить в адекватном виде - rdorn
  • How can you imagine this in json, for example, links - splincode
  • Depending on how you want to use it later, there are a lot of options and all with their own advantages and disadvantages. So the choice of exactly how the result will look after XML conversion => JSON is yours. The conversion method is in principle too. I don’t have enough JavaScript to write an example, but there are at least 3 options: XSLT transformation, manual parsing, any framework that can parse XML and / or generate JSON - rdorn
  • XSLT conversion, and there are articles on this topic? - splincode

0