We have extended our Early Bird Tickets for Inspire 2023! Discounted pricing goes until February 24th. Save your spot!

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer and Intelligence Suite.

Convert Input Data Table into XML struture processed by a Python Script

7 - Meteor

Dear Community,

I'm looking for a slick solution how I can convert a Table Input into an XML String which I can use in a Python Script.

I created a very simple setup.


With a very simple Python code:



# List all non-standard packages to be imported by your 
# script here (only missing packages will be installed)
from ayx import Alteryx

input_param = Alteryx.read("#1")
print (input_param)




In my Example the Table Select and the Python print Result look like this.

0 123456
1 341579


I need to convert the Table Data into an XML Format. The resulting format would look like this which I need to build into a SOAP WebService Body called by Python:








What options do I have?

- Doing everything in Python: How can I address and work with table data, I would need to loop all rows and address fields?

- Using Alteryx Objects: Which XML conversion or String Modification functions would you recommend?




17 - Castor
17 - Castor

Hi @S_Streck 


There's an XML Output macro on the Gallery that might be worth a try.



18 - Pollux
18 - Pollux

@S_Streck , @DavidP 


Just an update here.  


There seems to be an issue running this macro in more recent versions of Designer.  In 2020.3, you get an error(see this post).  In 2019.4, it runs fine.



7 - Meteor

Thanks for the Hint to the XML example in Alteryx.


This Makro worked in my 2020.4 Designer Version. It looks quite massive but it explains good how to do it.


I found in Addition this Video on Youtube, which explained how to use the Python integration.



So both worked for me, and I think I'll prefer the Python. Walking thru the Data table passed to Python looks simple for a one column List.

data = Alteryx.read("#1")
tag = 'item'
for element in data[tag]:
    print('<'+tag+'>' + element + '</'+tag+'>')