【问题】
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 datafields.
Any help is appreciated.
Regards, Frank
【回答】
取出 xml 中 members 一节的字符串,将它当 json 解析为二维表即可。用 SPL 的 json 函数可以解析。代码如下:
A | |
---|---|
1 | =file(“d:\\source.xml”) |
2 | =xml(A1.read()) |
3 | =A2.data.json_members |
4 | =json(A3).members |
Xml 文件如下:
运行结果:
A1:读取 xml 文件
A2:解析 xml 成序表
A3:读取 json 节点的字符串
A4:读取 json 转化为二维表