Can I convert Neo4J Database files to XML?
4 Answers
I agree, GraphML is the way to go, if you don't have problems with the verbosity of XML. A simple way to do it is to open the Neo4j graph from Gremlin, where GraphML is the default import/export format, something like
peters: ./gremlin.sh gremlin> $_g := neo4j:open('/tmp/neo4j') ==>neograph[/tmp/neo4j, vertices:2, edges:1] gremlin> g:save('graphml-export.xml')
As described here
Does that solve your problem?

- 6,311
- 1
- 21
- 24
-
your link is linking me to a blank github wiki page. perhaps you meant this page? http://github.com/tinkerpop/gremlin/wiki/Neo4j-Graph-Database – mmay Oct 22 '10 at 19:50
-
3The current information on loading/saving to/from Gremlin is now located here: https://github.com/tinkerpop/gremlin/wiki/Gremlin-Methods – nawroth Sep 03 '11 at 20:31
-
why not edit the original reply to fix the URL then? – George Birbilis Apr 07 '15 at 11:54
With Blueprints, simply do:
Graph graph = new Neo4jGraph("/tmp/mygraph");
GraphMLWriter.outputGraph(graph, new FileOutputStream("mygraph.xml"));
Or, with Gremlin (which does the same thing in the back):
g = new Neo4jGraph('/tmp/mygraph');
g.saveGraphML('mygraph.xml');
Finally, to the constructor for Neo4jGraph, you can also pass in a GraphDatabaseService instance.

- 5,750
- 7
- 53
- 72

- 1,702
- 12
- 13
I don't believe anything exists out there for this, not as of few months ago when messing with it. From what I saw, there are 2 main roadblocks:
- XML is hierarchical, you can't represent graph data readily in this format.
- Lack of explicit IDs for nodes. Even though implicit IDs exist it'd be like using ROWID in oracle for import/export...not guaranteed to be the same.
Some people have suggested that GraphML would be the proper format for this, I'm inclined to agree. If you don't have graphical structures and you would be fine represented in an XML/hierarchical format...well then that's just bad luck. Since the majority of users who would tackle this sort of enhancement task are using data that wouldn't store that way, I don't see an XML solution coming out...more likely to see a format supporting all uses first.

- 623,446
- 136
- 1,297
- 1,155
-
2I don't quite follow your point. XML is a metalanguage. GraphML is simply one instance of an XML markup language, specifically one used to represent graph data. So is RDF and XML Topic Maps (XTM). There is no limitation in XML per se in representing graphs, i.e., any SGML or XML markup language that contains links already does so. For example, DocBook **looks** like a hierarchical document format but given it contains links it can also represent a graph, just as can XHTML. – Ichiro Furusato Dec 05 '11 at 22:30
-
2(Got caught by the 5 minute edit rule.) As for explicit or implicit node IDs, that's an implementation issue. Most graph markup languages already have IDs on top level elements, and it's possible to add xml:id to any markup. Exporting from Neo4j to any markup shouldn't be a problem, it's just a serialisation, as indicated by Peter Neubauer above. – Ichiro Furusato Dec 05 '11 at 22:41
Take a look at NoSqlUnit
It has tools for converting GraphML
to neo4j
and back again.
In particular, there is com.lordofthejars.nosqlunit.graph.parser.GraphMLWriter
and com.lordofthejars.nosqlunit.graph.parser.GraphMLReader
which read / write XML files to / from a neo4j database.

- 17,616
- 8
- 52
- 80
-
1@jpp Well, I can reference source for specific java files, but they are classes with 100's of lines of code, so I won't be reduplicating that code here. – Stewart Feb 27 '18 at 21:35