XML Generator component - using the same attribute on multiple elements

Hi there,

I am trying to generate an xml file, which uses a lot of attributes.

One attribute, which is used quite often throughout the xml structure is the “xml:lang” attribute.

I would like to add the “xml:lang” attribute on the following elements: short-description, long-description, custom-attribute. It should look like this:

I tried to add a parent line in the control table for each element, but the attribute was only added to one of the three elements.

I was thinking about a workarond by adding multiple columns and change the output name with the display option in the control table. But the real XML file uses the xml:lang attribute on more than 30 elements, which would yield a very confusing workflow.

Here is a workflow with sample data.

Is it possible to add one attribute to multiple elements? Most likely @takbb could answer this quite easily?

Cheers

Hi @e2dboden ,

I’m new with xml and knime, but I’ve a suggestion… Sometimes, I convert the xml structure as a string, apply a string manipulation with regular expression and convert to xml again… can it solve for you?

If you put a demo here, maybe can help you with it.

Tks,

Denis

Hi @denisfi,

I posted a link to my workflow with some sample data in the post above.
The last node outputs an xml column. Maybe you could try and go from there.

Cheers,
Daniel

Sorry about it…

Well, I import yout project and at the component, I saw that you manipulate the string information and build the XML script.

My suggest is before the String conversion to XML, you add a string manipulation to add this info at the string if match and then, convert it to XML. At this point:

image

Just make this replace:

The result:

That’s it…

That would work. Thank you.

You’re welcome… if its solved, please, mark it to close this session, ok?

Seeya,

Denis

Hi,
your post was already marked as solution.
If there is anything else I need to do, please let me know.

Cheers

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