Good evening,
I was wondering if / how it’s possible to manage XPath declarations via variables. So to speak to dynamically define the amount of XPaths’ and for each a Columns name, XPath query, Type etc…
Thanks in advance
Mike
Good evening,
I was wondering if / how it’s possible to manage XPath declarations via variables. So to speak to dynamically define the amount of XPaths’ and for each a Columns name, XPath query, Type etc…
Thanks in advance
Mike
Hallo @mw,
Yes, you can use Flow Variables to dynamically define XPath query, column names, etc. If you use a Chunk Loop Start you can also dynamically define the amount of XPaths. Here is a small example workflow to show you how it can be done:
XPath_Dynamic_Columns.knwf (18.4 KB)
I hope this answers your question.
Best,
Janina
Hi @janina,
apologize for my late reply and thanks a lot for your suggestion. The challenge I was referring to is the amount of XPaths as their corresponding flow variables become available only after the array of XPaths was declared.
In other words, how can an variating amount of XPath declarations be configured via flow variables? The only approach I see is:
However, this still requires a lot of manual configuration steps basically neglecting the automation approach.
@ipazin Wouldn’t it be a great feature to pass an array pf XPaths like so to the XPath node to automate the node setup? Maybe this is “hidden” behind the flow variable "numberOfQueries), though?
Column name | Column name is XPath | XPath query | Return Type | Return missing on empty | Multiple tag options |
---|---|---|---|---|---|
Fixed title | false | //book/title | String cell | false | Single Cell |
//title | true | //book | Node cell | false | Single Cell |
The array index could dynamically be determined by the row line or manually set if necessary. In case a JSON is required the table should be able to get converted automatically too. What do you think?
The scenario / benefits would be:
Here is an example workflow based on that from @janina which explores the automation further.
Please note that, when trying to configure the “Return type” and “Multi tag options”, regardless of using the String values or indexes, I got the following errors:
WARN XPath 3:539 Errors loading flow variables into node : Coding issue: No enum constant org.knime.xml.node.xpath2.XPathNodeSettings.XPathMultiColOption.Single Cell
WARN XPath 3:539 Errors loading flow variables into node : Coding issue: No enum constant org.knime.xml.node.xpath2.XPathNodeSettings.XPathMultiColOption.0
This resulted in failure when trying to retrieve the column names dynamically in “Row6”:
Best
Mike
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.