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
#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?
Solved! Go to Solution.
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
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+'>')
I am unabe to search XML Output Macro.
User | Count |
---|---|
18 | |
14 | |
13 | |
9 | |
8 |