Here is my python code, I am trying to insert nodes and find relationships but it is taking more time, help will be appreciated
from xml.dom import minidom
from py2neo import Graph, Node, Relationship, authenticate
authenticate("localhost:7474", "neo4j", "neo4j")
graph = Graph("http://localhost:7474/db/data/")
i=0;
xml_file = open("sample.xml")
xml_doc = minidom.parse(xml_file)
archives = xml_doc.getElementsByTagName('archive')
class_names=xml_doc.getElementsByTagName('class')
label_Archive="Archive"
label="Class"
'Adding Nodes'
for arch in archives:
arc = graph.create(Node(label_Archive, arc_value=arch.attributes['name'].value))
topic_nodes = arch.getElementsByTagName('class')
for clas in topic_nodes:
cla=graph.create(Node(label,class_value=clas.attributes['name'].value))
e'].value))
**Adding relationship**
'This section adds relationship'
for arch in archives:
ARCID_=arch.attributes['name'].value
node = graph.find_one(label_Archive, property_key="arc_value", property_value=ARCID_)
for clas in topic_nodes:
ClassID_=clas.attributes['name'].value
node1 = graph.find_one(label, property_key="class_value", property_value=ClassID_)
try:
relationship_class=Relationship(node, "Class", node1)
graph.create(relationship_class)
IndexError:
continue