Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Parse XML independent of nesting level

JasonFriedman
6 - Meteoroid

I have some XML, pasted below and also attached.

 

<suite>
  <testcase id="001" kind="bvt">
    <inputs>
      <arg1>4</arg1>
      <arg2>7</arg2>
    </inputs>
    <expected>11.00</expected>
  </testcase>
  <testcase id="002" kind="drt">
    <inputs>
      <arg1>9</arg1>
      <arg2>6</arg2>
    </inputs>
    <expected>15.00</expected>
  </testcase>
</suite>

 

I'd like Alteryx to ingest this as:

 

id kind arg1 arg2 expected
1  bvt  4    7    11
2  drt  9    6    15

 

I have a solution attached and pictured below:

 

First stepFirst stepSubsequent stepSubsequent step

 

That subsequent step would need to be repeated, I think, if the XML nesting was deeper.

 

Is there a solution that will work no matter how deep the nesting?

19 REPLIES 19
DavidP
17 - Castor
17 - Castor

Try this macro - it parses all child levels into a flat structure.

 

 

DavidP
17 - Castor
17 - Castor

load your file as a csv and choose \0 as the delimiter then connect the output to the parse XML macro.

JasonFriedman
6 - Meteoroid

Thank you, DavidP. Let me load it up and check it out.

JasonFriedman
6 - Meteoroid

Hello DavidP, I'm getting an error:

 

The configurationThe configuration

 

log.png

DavidP
17 - Castor
17 - Castor

Attached workflow package uses Parse XML macro to load your sample file.

 

 

DavidP
17 - Castor
17 - Castor

You Shouldn't edit the macro file.

 

The Input data tool in the workflow calling the parse xml macro should be set as csv with \0 delimiter and uncheck first row contains headers

JasonFriedman
6 - Meteoroid

Ok, I'm new enough that I don't know how to use a macro yet.

 

I will report back in a few days after I figure out how to do so.

DavidP
17 - Castor
17 - Castor

Just extract and run the workflow I attached to my last post

MikeN
Alteryx Alumni (Retired)

Thanks @DavidP - I also grabbed the data and the macro and it doesn't seem to return the results @JasonFriedman is looking for.

Curious if you tested the macro against the xml file (so it would be just my user error stopping me from getting the results)?

Labels