Extracting a JSON array from an XML File
【Question】
Hi there,
I want to evaluate a json-array that is stored inside a xml-file, e.g.:
Real Madrid
<json_members>{members:[{member_name:sergio,member_since:2010},{member_name:alonso,member_since:2007}]}</json_members>
I need to do that this way because the internet gateway our company uses does not support filling the database with an unknown number of data fields.
Any help is appreciated.
Regards, Frank
【Answer】
Retrieve strings under the members node and parse them as a two-dimensional table. It’s easy to do this using SPL json() function. Here’s the SPL code:
A |
|
1 |
=file(“d:\\source.xml”) |
2 |
=xml(A1.read()) |
3 |
=A2.data.json_members |
4 |
=json(A3).members |
The XML file:
Result of executing the SPL script:
A1: Import the XML file;
A2: Read the XML file as a table sequence;
A3: Retrieve strings under JSON members;
A4: Read the JSON array and convert it into a two-dimensional table.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL