Column to XML node Output sorting

Hi All,
I have following problem i want to build an KNIME application which transforms Excel to XML , so I used the Column to XML Node to convert my Test-Row to XML.
It´s very important that the Elements of the XML-File are in a certain order, but it seems like the Column to XML Node sorts the elements automatically in alphabetical order.

Does someone know how to change the order of the XML-Elements in the output data?

Thank you

Hi @MaxS123,

as far as I know - according to the XML specification, it is not important.
“the order of attribute specifications in a start-tag or empty-element tag is not significant”
…so I think KNIME does the correct thing here and do it alphabetical

But you could trick KNIME to do the order you want anyways.
Name your attributes with an unique prefix
e.g. C1_ --it should be something which does not appear in your XML content

Then replace the prefix with a string manipulation node or string replacer afterwards

Output has the correct order

Example workflow:
KNIME_project31.knwf (8.0 KB)

However like stated above…I think you are using the XML not like it is in the specification of XML.
At least as far as I know / a quick google search told me :stuck_out_tongue:

1 Like

*you could also do it with prefixes which are in your xml - then you’ll have to make an regex-replace which captures the whole tag

@MaxS123 did this work for you? Or did you need something else?

If that fixed your issue - could you please close the thread?

1 Like

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