Hi everyone. I am a new Alteryx user and would appreciate some assistance in solving an issue I'm having with creating a loop for parsing a xml file. For simplicity, let's start with a single field that I'll call InfoGrp. Here's what I'm doing:
This all runs fine, but here's where I run into my issue. I don't just have one InfoGrp field; I have several (e.g., InfoGrp, InfoGrp_2, InfoGrp_3, etc.), the number of which could change, depending on my source file. I was able to figure out a way to count the number of InfoGrp fields, but here's where I get stuck. If I was programming this, for example, I'd create a loop with 2 variables: one for the count, which would decrease each time I ran my loop, and one for the selection name, which would increase with every loop (i.e., 'InfoGrp_' + variable + '_OuterXML'). Unfortunately, I have no idea how to do this in Alteryx. My thanks to anyone who can provide me with some guidance.
Solved! Go to Solution.
Can you provide a sample input file. With this we should be able to provide you with a relatively simple workflow.
Thanks
Dan
Any luck with this file? Please let me know if you have questions.
Parsing XML is tricky with Alteryx. There is no simple way to tell Alteryx to give you a tree based on an arbitrary XML file. I find that the best way is to parse your file is level by level, pulling out either the child values and/or the outer_xml depending on what you need from each level.
This work flow parses each level in turn and builds out the data contained within each node. The 2 outputs return either the data by columns or by rows as shown below
Note that when your dealing with XML, you data set can balloon very quickly. This is because the outer_xml of all the higher level elements is included in each row, so if your initial XML file is 2MB is size, you have a 2MB string in each row of your output. The way to deal with this is to use Select tools between the XML Parse tools to remove the outer_xml for levels that you've already processed.
Dan
Brilliant! I see where I was going wrong now and need to revisit my understanding/use of returning Child Values. Thank you so much!