Some workflows that I played with for generating XML

I looked at various resources on the forum and elsewhere for the creation of XML, both simple and complex (nested), but none of them quite answered my question (maybe I didn’t look hard enough, lol !).

I wanted to be able to create xml from one or more data tables, both in simple form and with nesting. Whilst Table to JSON followed by JSON to XML provided a quick way of turning a single table into xml, in my view it lost flexibility and didn’t handle nesting of a more complex XML structure, so I set about trying to put together a basic workflow example for replicating that simple form (one table becomes one xml file) without the JSON nodes.

The result of that was this first basic workflow.

With that worked out, I didn’t like the fact that I was having to hand craft a node for every column (which was one of the advantages of letting the JSON nodes do it for you!), and so I figured this part would have to become a loop. I also discovered that if my columns had spaces in the names, the process would fail so I needed to have something “standardise” my column names. So I create two reusable components to be slotted into the workflow without having to put the loop in the workflow. The components themselves do the looping through the columns:

and built this into a new “Simple XML” generation workflow

and then finally I decided that with this working, I needed to see how I could generate XML containing some nested information, so that two data tables could come together and be used to output as a single XML

I thought I’d share this as I know that just occasionally the same questions that I was asking myself come up on the forum. Enjoy and please do let me know if you spot bugs or you think of better, cleaner, or more efficient ways to do this!

6 Likes

I couldn’t find all columns to xml node in Knime. I am on ver 4.4.4. Is this available in later versions? Sorry, I am new to the tool

Hi @sudhirkumra , welcome to the KNIME community!

The “All Columns to XML” is a component (a packaged up set of nodes) rather than an actual node so you won’t find it in the Node Repository within KNIME.

Instead, click on here:

to open the page containing that component on the KNIME community hub. Once there, if you have a KNIME workflow and that web page open side by side, you can drag and drop the component onto your workflow

(KNIME 5.x / Modern UI)

(KNIME 4.x / Classic UI)

By the way, I think that was one of the first components I wrote (I started using KNIME in Mar 2021), so I hope it still works! I’ve discovered quite a few things about the way KNIME works since then (and there are some misconceptions I may have had as a beginner), so it is quite possible that this article doesn’t reflect the best way to do things now, but I hope it is useful even so!

@takbb thanks for the reply but when I try to drag and drop the component on my work flow, it says invalid url and this can’t be dropped to the workspace!

Hi @sudhirkumra , I don’t know why that should be.

Are you perhaps connecting through a proxy server, or do you have security restrictions on what you are able to download?

Could you upload a screenshot of the error message, and also take a look in the console log (use the menu View - Console if the console panel is not already displayed) , and see if there are any additional messages there.

Knime_Error.docx (18.9 KB)

NO additional messages in the console log

hi @sudhirkumra , thanks for uploading the screenshot, as that shows the specific wording of the error message.

It sounds similar to this post:

I’d suggest taking a look at the links/suggestions in that post as I wonder if yours is also related to network security, and in particular use of a proxy server for connecting to the internet. Are you running KNIME in a company/corporate environment?