Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!

Help with custom macro for parsing XML document

7 - Meteor

I have created an iterative macro for parsing an XML field in a table into a flattened format but I'm having a bit of trouble finishing it off. 
 

The issue arises as not every record has all of the fields, so when I try to use a select tool within the macro, if the field doesn't exist in that specific record, I get a "no valid field was selected" error and the macro fails. Does anybody have any idea on how to fix this?

For example, a record may be:

 

<product> <airline> <id> foo <\id><name> bar <\name><\airline> <\product>

 

To parse this I used xml parse on the field looking for the child element <airline> and returning the outer xml. I then used the select tool to filter to just the outer xml field and another xml parse tool to get the child elements id = foo, name = bar. I can't just use a single xml parse tool specifying "specific child name" = "id" as there are multiple id fields in the document. 

My issue comes when I try to parse an iteration where there are no elements called <airline>, the select tool doesn't find airline_outer_xml as a field and erros, failing the macro.

 

Any help would be much appreciated!

Alteryx failing.png

(The area where my workflow breaks down. The top tools are when it's working i.e. <airline> exists in the document, the bottom is where it fails i.e. when <airline> does not exist)

Highlighted
11 - Bolide

Hi @JonnyR,

 

Could you possibly share your iterative macro here? If you export it by going to Options -> Export workflow it will include all necessary files.

 

 

Highlighted
7 - Meteor

Would you need the template input file for the macro as well? This currently has some sensitive customer information in it which I'll need to remove first if so. Thanks for your help!

Highlighted
11 - Bolide

It would be best if you could send the file in which you are implementing the macro. If you send the zipped file (exported the way I describe above) it should include the macro itself and any template data.

 

And I totally understand about not wanting to share sensitive data-- any sample data would help, as long as I can recreate the problem.

Labels