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$
4
  • $\begingroup$ Please attach a .blend so we can more easily work on your question $\endgroup$
    – WhatAMesh
    Commented Aug 11, 2018 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$ Commented Aug 11, 2018 at 13:55
  • $\begingroup$ I'm not sure either, anything would work for me. Dropbox? $\endgroup$
    – WhatAMesh
    Commented Aug 11, 2018 at 14:00
  • 1
    $\begingroup$ there you go, google drive link $\endgroup$ Commented Aug 11, 2018 at 14:08

1 Answer 1

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$
1
  • $\begingroup$ Yes! that was it, I had tried .fromstring but the getroot() was blocking it. thanks! $\endgroup$ Commented Aug 11, 2018 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .