二郎代码:
-module(index).
-compile(export_all).
-include_lib("erlsom/include/erlsom.hrl").
start(Port) ->
misultin:start_link([{port, Port}, {loop, fun(Req) -> handle_http(Req) end}]).
stop() ->
misultin:stop().
handle_http(Req) ->
Var = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><code>1</code><var1>123456</var1><var2>qwerty</var2></request>",
XmlErlsom = erlsom:simple_form(Var),
Req:ok("~s", [Var]).
在我编译代码并启动服务器后,我打开了 localhost:8080/,shell 给了我以下错误:
http process <0.196.0> has died with reason: {badarg,
[{erlang,list_to_binary,
[[{ok,
{"request",[],
[{"code",[],["1"]},
{"var1",[],["123456"]},
{"var2",[],["qwerty"]}]},
[]}]]},
ChicagoBoss 的相同 lib 'erlsom' 成功运行......
之后我尝试使用 xmerl,但结果相似。