XML: replace some values with new values (based csv) and convert It back to (Original XML)

Hi @Felipereis50,
Thank you for sharing your situation. It seems more challenging. I think the columns in the second table need additional information to distinguish the XML tags. I had to resort to string manipulation and tried it with KNIME, so it ended up becoming quite complicated. :sweat_smile:

XML_REPLACE_tark 2.knwf (261.3 KB)

This is a sample xml I prepared. There are two CPF values with different parent elements.

<contribuinteEmitente> ... <CPF>012345678</CPF>
<contribuinteDestinatario> ... <CPF>01280332239</CPF>

This is a sample table for replacing XML values with new ones. Here are the rules:

  • The column names should match the XML tags.
  • If there are identical XML tags, add one parent name to the column name to distinguish the tags.

In this example, do as follows:

<contribuinteEmitente>CPF
<contribuinteDestinatario>CPF

With this, the preparation is complete. When you run the workflow, the values should be replaced. However, I’m not confident it will work for other cases and it’s a complicated workflow. I hope a more efficient solution can be found.

Output

2 Likes