Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-24-2021 01:34 AM
Hi,
I am new to cypher. I was trying to load a XML document using apoc procedure. The XML file has 37 elements (plus one header element and export element).
When I am trying to return the elements I am getting 79 results, duplicated with NULL values. Why is that so?
But when I used count , It return only 37 elements.
11-27-2021 02:00 AM
1 ) Regarding your XML, it could be better if you can provide an example of the file to analyze if there is anything specific on it. But, in general, null values appears on elements that doesn't have the required property. For example, with my following XML:
<root>
<prod productId="1000N7Z800"/>
<prod productId="1000M7Z810"/>
<client clientId="CL11000M7Z810"></client>
</root>
And with the following Cypher Query
CALL apoc.load.xml("file:///products.xml") YIELD value UNWIND value._children AS Product RETURN Product.productId
It will return only 2 non-null productId and one null value, because we have one element (the client one), that doesn't have a productId attribute.
So check if you have any element that doesn't have the productId attribute or if there are non products values ). Besides, make sure your most updated XML was located in the DBMS import folder (as this is the default folder where the apoc library will load the files from).
2 ) On Neo4J, the count operator returns the quantity of non-null values (when you apply it on given columns). As in your case there are only 37 non-null ProductIds, the count is returning that number (and discarding the null values).
Hope this helps.
All the sessions of the conference are now available online