cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

loading XML data failure

OmarHamdy
Node Clone
CALL apoc.load.xml("file:///xxxx/xx.xml")
YIELD value
UNWIND value._children AS GraphicElements
WITH GraphicElements,GraphicElements._children as EmbeddedSymbols
with GraphicElements, EmbeddedSymbols, 
[in EmbeddedSymbols where x._type = 'EmbeddedSymbol'][0] as embeddedSymbol
with embeddedSymbol.Name as name,embeddedSymbol
return embeddedSymbol,name
 
EmbeddedSymbol is an XML tag and name is property of this tag , this query returned 5 null records and 1 non-null record , actually I need to create "EmbeddedSymbol" Node and Set "Name" as its unique property .
 
so i wrote the following query to check if the value is not null and pass name value to it but i faced a lot of errors :
 
CALL apoc.load.xml("file:///xxxx/xx.xml")
YIELD value
UNWIND value._children AS GraphicElements
WITH GraphicElements,GraphicElements._children as EmbeddedSymbols
with GraphicElements, EmbeddedSymbols, 
[in EmbeddedSymbols where x._type = 'EmbeddedSymbol'][0] as embeddedSymbol
with embeddedSymbol.Name as name,embeddedSymbol
call apoc.do.when(
    embeddedSymbol IS NOT NULL,
'MERGE (e:EmbeddedSymbol{Name:name})',
 {name:name}
)
 
The current Error is : 
Type mismatch: expected String but was Map (line 11, column 2 (offset: 461))
" {name:name}"
2 REPLIES 2

The third parameter of the apoc.do.when statement is supposed to be a string representing the cypher query to executed when the conditions is false. You have passed a literal map '{name:name}' instead.

Okay I understand the error but what should I do?

Because i tried alot of fixes but none of them worked for me

I tried {name:name} , name:name, name:$name

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online