Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

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

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

S_Streck
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.

S_Streck_0-1611310762025.png

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
#Package.installPackages(['pandas','numpy'])

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

 

 

 

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

   Key
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:

 

 

<SR_KEY>
 <item>123456</item>
 <item>341579</item>
</SR_KEY>
 

 

 

 

 

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?

 

 

 

4 REPLIES 4
DavidP
17 - Castor
17 - Castor

Hi @S_Streck 

 

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

 

https://gallery.alteryx.com/#!app/XML-Output/565bfd4caa690a12542665e3

danilang
19 - Altair
19 - Altair

@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.

 

Dan

S_Streck
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.

https://youtu.be/JJ3D5HIkFc0

 

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+'>')

 

Alteryx is one of the top data analytics platforms, and Python is amongst the hottest programming languages. So what happens when you use both together? In this webinar, we'll show you that the sky is the limit when you combine Alteryx and Python. We will go through 1. The basics of the Python ...
rohit782192
11 - Bolide

I am unabe to search XML Output Macro.

Labels