cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

APOC - apoc.load.xml

dionisios95
Node Clone

Hello guys, 

I have an issue and could need some help, because its a bit frustrating. 

I wanted to use the apoc.load.xml to import some data and create also Nodes and Properties with them.

I've tried this one and it worked well: 

code3.png

The Graph-Part should look like this (executed 3 times) : 

nodes.png

 The grey and Green nodes will be created and the other exist allready. 

My problem is, that it doesnt work with several childrens (level).

I've tried this and got nothing (no changes, no records): 

code2.png

The Ressource-Node (pink) already contains the value "oversight", without "-info".   

The hierarchy of value.children looks like this (needed parts)

hierarchie.png

hierarchie2.png

 Would be nice to get some advice what to do next. Did I missed something or missunderstood?

 

1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

Sorry, it is very difficult to solution this without the xml.  I tried my best to reverse engineer it from your second query and the screenshot of the root from the xml load. I could not test it without the xml. Let me know if there are issues and we can try to resolve them.

call apoc.load.xml("file:///file.xml") yield value
with value._children as root
with [x in root where x._type = "oversight_info"][0]._children as oversight_info,
     [x in root where x._type = "id_info"][0]._children as id_info
with [x in oversight_info where x._type = 'has_dmc'][0] as has_dmc
     [x in id_info where x._type = 'ncd_id'][0] as ncd_id
match(r:Resource{ns1__title: "oversight"}) 
merge(o:Oversight{has_dmc: has_dmc._text}) 
merge(t:Trial{nctid:ncd_id._text})
merge(o)-[:SCO]->(t)  
merge(o)-[:INCLUDE]->(:Resource{ns1__title:'has dmc'})
merge(t)-[:IN_CAT]->(r)

 

View solution in original post

4 REPLIES 4

glilienfield
Ninja
Ninja

I am confused on what you want. Each query does different things. Can you explain what result you want from the xml? Are you able to share the xml file? 

I want the same result like the first part with the url-value on the file: 

- New Node "Oversight"(Grey) with the Prop. "has_dmc" and their value from the xml 

- New Node "Trial" (Green) with the  Pro. "nct_id" and their value from the xml 

- Rel.:  :Oversight -SCO-> :Trial  -IN_CAT-> :Resource(Pink)

- The Resource-Node already exist and has the Prop. ns1__title: "oversight"  #

I've tried this one (~30:28) https://www.youtube.com/watch?v=WdClRB_-Egs , but with creating Nodes´, not RETURN 

I am not able to share an xml file here, but this is the part you need: 

<clinical_study>
<!-- This xml conforms to an XML Schema at:
https://clinicaltrials.gov/ct2/html/images/info/public.xsd -->
<required_header>
<download_date>ClinicalTrials.gov processed this data on June 24, 2022</download_date>
<link_text>Link to the current ClinicalTrials.gov record.</link_text>
<url>https://clinicaltrials.gov/show/NCT00170157</url>
</required_header>
<id_info>
<org_study_id>MC0253</org_study_id>
<secondary_id>NCI-2009-01214</secondary_id>
<secondary_id>MC0253</secondary_id>
<secondary_id>P30CA015083</secondary_id>
<nct_id>NCT00170157</nct_id>
</id_info>

.........

<oversight_info>
<has_dmc>No</has_dmc>
</oversight_info>

.......

</clinical_study>

glilienfield
Ninja
Ninja

Sorry, it is very difficult to solution this without the xml.  I tried my best to reverse engineer it from your second query and the screenshot of the root from the xml load. I could not test it without the xml. Let me know if there are issues and we can try to resolve them.

call apoc.load.xml("file:///file.xml") yield value
with value._children as root
with [x in root where x._type = "oversight_info"][0]._children as oversight_info,
     [x in root where x._type = "id_info"][0]._children as id_info
with [x in oversight_info where x._type = 'has_dmc'][0] as has_dmc
     [x in id_info where x._type = 'ncd_id'][0] as ncd_id
match(r:Resource{ns1__title: "oversight"}) 
merge(o:Oversight{has_dmc: has_dmc._text}) 
merge(t:Trial{nctid:ncd_id._text})
merge(o)-[:SCO]->(t)  
merge(o)-[:INCLUDE]->(:Resource{ns1__title:'has dmc'})
merge(t)-[:IN_CAT]->(r)

 

Thank you very much. I did not knew, that I can make seperate "with" with the use of the new variable. I thought I have to unwind that stuff.