hbmartin / graphviz2drawio

Convert graphviz (dot) files to draw.io / lucid (mxGraph) format. Beautiful and editable graphs in your favorite editor.
https://pypi.org/project/graphviz2drawio/
GNU General Public License v3.0
186 stars 32 forks source link

Error in parsing the graph for xml conversion with `fdp` #68

Open pandey0039 opened 4 months ago

pandey0039 commented 4 months ago

Hi Everyone, I made the graph with pydot library using "fdp" layout parameter and also giving position for each nodes for the graph. While converting the graph to xml, it is giving error as :

Traceback (most recent call last):

  File ~\AppData\Local\anaconda\Lib\site-packages\IPython\core\interactiveshell.py:3505 in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  Cell In[160], line 3
    xml = graphviz2drawio.convert(gdt)

  File ~\AppData\Local\anaconda\Lib\site-packages\graphviz2drawio\graphviz2drawio.py:26 in convert
    nodes, edges = SvgParser(svg_graph).get_nodes_and_edges()

  File ~\AppData\Local\anaconda\Lib\site-packages\graphviz2drawio\models\SvgParser.py:14 in get_nodes_and_edges
    root = ElementTree.fromstring(self.svg_data)[0]

  File ~\AppData\Local\anaconda\Lib\xml\etree\ElementTree.py:1338 in XML
    parser.feed(text)

  File <string>
ParseError: not well-formed (invalid token): line 64, column 109

Some relevant code info is as follows which I find was different than usual standard code:

# Create an empty PyDot graph
G_pydot = pydot.Dot(graph_type='digraph',layout="fdp")

pydot_node = pydot.Node(str(node), label=item['text'],shape=get_shape(item['shape_type']),slane=key,pos=f"{X},{Y}!") 

# Add the PyDot node to the PyDot graph
G_pydot.add_node(pydot_node)`

gdt=G_pydot.to_string()
xml = graphviz2drawio.convert(gdt)
hbmartin commented 3 months ago

I'm not familiar with PyDot, can you post the result of G_pydot.to_string() ?