I’m trying to parse a XML-like file test.xml (795.2 KB). What I need is all the tableRowValues that are in the “attachment” tag where the attribute name=“TICs”, e.g.
I’ve tried with “XML reader” and “XPath” nodes but without success. Any idea?
If the problem is that the XML Reader fails, then you could try the following…
This is a bit of a guess, but try using a Load Text Files node from the Vernalis community plugin, then follow that with a String Manipulation node, with
replace($File Content$, "<?xml-stylesheet type=\"text/xml\" href=\"#openms-qc-stylesheet\"?>", "")
as the body (replace ‘$File Content$’ with the colum from the load files node). Finally, try a String to XML node. My guess is that the XML reader is looking for the xml-stylesheet and not finding it and so failing. If you remove that from the text first then it will probably be ok.
I attach a workflow that extracts your values. I converted the XML file to JSON and then used the JSON path editor to define a path. The tricky thing is to find the path. That took some time. I exported the JSON file and used an editor (Atom on MacOS) to find the right row. Then you would have to click on an item you want and hopefully it would select and mark blue the values you want. I am not a JSON expert so I would have to click around until it fits.
Then the workflow would ungroup the values and just keep the column with the values. The name of the column the node selects is “texts” but you could change that.
[Edit: I just see the values I extracted might not match your exact values, you might have to try again to find a path or check the results]
kn_example_xml_like_file.knwf (1.3 MB)
thank you, it works fine!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.