erlang一般用xmerl这个库来解析xml。
应变成像: - [[{"name", "The Name!"}, {"reviews", [{"review-by", "WE"}, {"review-points", 92}], {"review-by", "WS"}, {"review-points", 90}]}
复制代码
我照着最后生成的是这样的:跟上面的差别很大。
- 7> demo:parse("demo.xml").
- [{item,[{'review-points',"90"},
- {'review-by',"WS"},
- {'review-points',"92"},
- {'review-by',"WE"},
- {name,"The Name!"}]}]
复制代码 而且这个模式匹配必须要知道内容:比如要知道有个Item标签
- extract({xmlText, [{name, _}, {'Item', 2}, _], _, _, Value, text}, Acc) ->
- [ Acc | {item, ItemData} ];
复制代码 怎么写一个比较通用的xml解析文件?
求大神解答。。。
|