2
$\begingroup$

I've an XML which includes position and rotation information and which I need to parse it in order to use it with animation nodes. This is something I already managed to do via python scripting but as its much easier to interact with nodes I would like to replicate it within AN. My problem is that even if my script works it seems that things are done differently in AN, somehow importing the xml.etree library has no effect on my xml, this is how it looks now:

enter image description here

I'm almost sure it has something to do with how I'm using inputs but as I'm new to coding I can't figure it out. As you can see in the image it seems that the node script can`t access the file input (xml).

Any ideas on how it should be done? Thanks in advance

https://drive.google.com/file/d/11N7AeNxEntrfEwEGfwxQ-vvX_lviD1mP/view?usp=sharing

$\endgroup$
  • $\begingroup$ Please attach a .blend so we can more easily work on your question $\endgroup$ – WhatAMesh Aug 11 '18 at 13:24
  • $\begingroup$ Done. I'm not sure how to share the xml, so if needed i'll be happy to post it via a link. $\endgroup$ – Juan Manuel Lynch Aug 11 '18 at 13:55
  • $\begingroup$ I'm not sure either, anything would work for me. Dropbox? $\endgroup$ – WhatAMesh Aug 11 '18 at 14:00
  • 1
    $\begingroup$ there you go, google drive link $\endgroup$ – Juan Manuel Lynch Aug 11 '18 at 14:08
1
$\begingroup$

The ElementTree.parse() function takes a filename or file object for the xml file as an argument. In your script node, xml is a string and not a filename or a file object and hence the error.

Instead, you can use the ElementTree.fromstring() function which takes a string representing the xml file. Note that the output is the root of the tree and thus getroot() needn't be used.

See the documentation.

$\endgroup$
  • $\begingroup$ Yes! that was it, I had tried .fromstring but the getroot() was blocking it. thanks! $\endgroup$ – Juan Manuel Lynch Aug 11 '18 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.