KNIME is great at reading and extracting information from XMLs, but I would actually like to replace values in an existing XML.
At the moment I can use the XPath node to extract the values I would like to change. I can then change these values (String replacer), but after that I am a bit lost of how to add this value to the the original XML. Is there a way to do this?
If I use the Column to XML node and the XML column Combiner to the original XML, it just puts my new data at the end of the original XML.
I really need KNIME to edit the contents of on existing XML. Is this possible in KNIME?
Any advice would be most welcome.
if you want to replace something very simple you can use the string manipulation node.
For more advanced queries I would recommend the XSLT node. XSLT is a translation scripting language for XML documents (https://en.wikipedia.org/wiki/XSLT)
Best regards, Iris
I am a long time user of KNIME and a participant at a number of KNIME UGMs that includes the Spring summit in Berlin earlier this year.
It would be great if you tested your answers before posting. The String Manipulation renders all downstream XML nodes along with the XPath node as unusable, so this solution is about as helpful as a chocolate teapot.
The second solution goes against the underlying value of KNIME. If I wanted to script code to carry out my data transformations then I do not need KNIME. All functionality to transform/manipulate data in whatever format should be part of the KNIME application.
I am not sure in which direction KNIME is planning to go in the future, but I feel I have reached the limit of what KNIME can do for me. Time to look at other options I think.
> It would be great if you tested your answers before posting. The String Manipulation renders all downstream XML nodes along with the XPath node as unusable
Use the String to XML node aftet you've performed the replacement
> If I wanted to script code to carry out my data transformations then I do not need KNIME.
Just creating the XSLT won't solve you problem. You'd still need a tool to apply it.
> I am not sure in which direction KNIME is planning to go in the future, but I feel I have reached the limit of what KNIME can do for me. Time to look at other options I think.
You can do what you want in KNIME, it's just not as easy as you'd like it to be as the advance XML manipulation is done using XSLT, otherwise you need to treat your XML as a String as per Iris' comments. Maybe make a feature request?
yes you are right, my answer was missing the String to XML node right after the String Manipulation node.
You can as well ues the String Replacer on the XML Column. But it will produce a String Cell afterwards. The String to XML will than convert it back to XML. (Which you can than use with the XPath node)
Best regards, Iris
Thanks Iris & Sam
Your recent posts are very helpful. Maybe the String Manipulation/Replacer nodes can be enhanced to allow XML Columns to stay as XML, this would cut out the need to keep converting back.
Thanks again for your full explanation.