XML multiple files output

I need to create multiple XML files.
The two input files I have here are linked to each other via the ‘Key’ column.

In the attached example, I need to create 6 xml output files

C0046658.XML
C0047841.XML
C0047843.XML
C0047845.XML
C0047847.XML
C0048505.XML

Each file will contain one set of parent and child records

e.g. C0046658.XML will contain following records

C0046658
C0047184
C0047185
C0047186
C0048782
C0048783

C0047841.XML will contain records

C0047841
C0048784
C0048785
C0048786
C0048787
C0048788

I am now going to embark on my mission to find out how to put all this together !!
Wish me luck.


Input Table04.xlsx (11.2 KB) Input Table03.xlsx (9.9 KB) XML Output.knwf (23.0 KB)

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.

XML Output_SF.knwf (71.8 KB)

2 Likes

Hi ScottF,

Can we make xml at once? means combine all columns at once, not column by column

see my workflow

is it possible if we’ve six columns in a excel file and we want to make it’s xml just once

looking forward to hearing from you.

many thanks,
rao

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)

Gets output as follows

        <TP_Column_02>N</TP_Column_02>
        <TP_Column_03>
        </TP_Column_03>

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.

1 Like

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!)

  • Brian
3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.