What about something like this? It doesn’t incorporate all of the logic you were interested in, but maybe that’s not necessary. My changes in red annotation, mainly to involve a sort prior to a small loop.
I too am relatively new with Knime and would like to know the answer if there exists one.
It is painful to convert the columns one column at a time.
Plus if the column value is blank, then the knime workflow still creates 2 lines for the column.
This gets read as white spaces rather than a blank or null value at the receiving end. Its not an accurate representation of the data structure.
Example:
TP_Column_02 = N
TP_Column_03 = ‘’ (blank)
In the above example TP_Column_02 was output correctly it has a value N.
TP_Column03 has a blank value.
In spite of the blank value, it has got two lines in the output.
I would have thought the workflow should output it as simply </TP_Column_03>
I changed my logic at the reading end to work around the issue.
It’s been a few months since this thread so you may well have moved on with this already, but I’ve been trying out Knime’s xml features and thought this may help you, or others. I agree that individually generating xml columns one at a time is cumbersome. The alternative that I’ve seen ( [Table to JSON] followed by [JSON to XML] ) is quick-and-dirty but in my view loses too much control over the output.
As a demonstration of my thoughts on this, I have put the processing of the columns into a loop which creates xml for all columns in a supplied data table. (Any columns that are not required should be filtered out prior to passing the table to the component, and then re-joined on the other side, using something like a Column Splitter (see my “nested” example workflow below)
See this:
As a simple example of its use in a workflow, see the following sample workflow:
For a slightly more complex example, to demonstrate how two tables could be used to create a piece of nested xml, see this workflow:
(These are my first attempts at putting things on the public hub, so hopefully they work!)