Problems with parsing a XML-like file

Hello

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.

0.06304059198 118759464
0.444749184 134730432
0.821746656 126575480
1.19846315202 119222952
1.579326144 116276016
1.95593856 119685872
2.33203868802 115389088
2.70814657602 119230392
3.083884113 118585048
3.464118048 124508512

I’ve tried with “XML reader” and “XPath” nodes but without success. Any idea?

Thank you!

Roger Olivella

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.

Steve

Thank you! I’ll try it!

Roger

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)

3 Likes

thank you, it works fine! :slight_smile:

1 Like

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