community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Tags of XML

Meteor

Hi,

 

I would like to get all the tags in a XML file(in blue).

 

a.png

Is it possible?

You just want the tags?

 

Sounds like a job for RegEx.


Although someone else may have a different way, the way I would do it is:

Add a TextToColumns Tool, split the field to rows on delimiter: \n

(new line)

Then, add a RegEx tool with output type = Parse, using the regular expression:<(\w+)>.*

 

XML_Text_To_Rows.pngParse_Tag.png

Alteryx Partner

If all of the records contain the same tags / nodes, you could just read in the first record, XML parse it, and then transpose the result.

Meteor

Hi @patrick_mcauliffe,

 

I did as you said, but my output are null?

 

@ARaju2

 

Was the screenshot in your first post the exact set of data you are working with?

If the XML wasn't that clean, then you may have to modify the RegEx to account for other characters.

 

For example, if any of your tags have a space in them:

When I recreated your screen shot:

XML_Sample1.png

 

 

 

But let's say that one of the tags was anything other than a single word.  For example, if it had a two words with a space between them:

 

XML_Sample2.png

 

 

See how I modified the RegEx to account for the fact that there may or may not be a space?  \s = space \s*=zero or multiple spaces

Same thing with the second word.  The \w got an * also to show that it may or may not exist.

 

 

 

Also, and again depending on how clean the data is, @PeterGoldey's solution may work for you as well.  The reason I didn't go there first is because I assumed you didn't have clean data.  Depending on how you got to the XML/if any modifications happened to it already, the XML parse tool may not catch all of the tags or may need to be iterated through a few times.

 

Remember, there is always more than one way to get something done with Alteryx, so don't strictly focus on a single person's suggestion.

 

 

Alteryx Partner

To add to the above, in a GIANT XML file that I parse each day, not every record has all tags (or even all nodes).

 

In that case, you need to parse a substantial set of the data, then transpose, then do a summarize to get all the unique tag names out of the "name" column (after transpose, the tags will be names and the data will be "value").

 

If there are nested multiple sub-nodes, then you actually have to as sub steps parse those and transpose them and repeat.

 

So 100% agree my suggestion is only good for the use case I mentioned...but if that is your use case it will be very simple.

 

- Pete

Meteor

Thank You @PeterGoldey and @patrick_mcauliffe,

 I went through both of you suggestions and came out with a workflow that works as I wanted.

 

Actually my input is folders of alteryx workflows then using XML Parse to get specific tag but certain of the workflows have tool containers.

So is there a way to remove tool containers but not the data in the tool containers.

@ARaju2

Of course there is.  It depends how you got to the point where you're ready to remove data and what you want to do with it after you remove the container.

Are you basically wanting to re-write your workflows in batch, removing all tool containers at once?

 

 

Highlighted
Meteor

HI @patrick_mcauliffe,

 

I would like to use any Alteryx Workflow as my input and before I start with my data transformation , I would like to disable any tool container in the workflow.

 

 

input(Alteryx Workflow) ---- > disable Tool Container ------> Data Transformation.

 

Thank You

Hey @ARaju2

There are so many cool ways you could do this.  It wouldn't necessarily have to be through editing the xml, but that probably is the fastest way to get started.

 

I've attached a very basic example.  "ContainerEnabled.yxmd" is just an example I used as a template.  If you open that up in your favorite text editor you see that the node is identified as a container seven lines above the line that identifies it as enabled or disabled.  So in the workflow that does the disabling ("DisableContainer.yxmd"), I just used a Multirow tool to identify the node and the property, then used a Replace function to disable it.

This is just a starting point. Depending on how complex you want to be, you could make this into a macro that will then run the workflow after complete.

Labels