Используйте xmerl
для создания XML на Erlang:
1> MysqlResult = {selected,["id","first_name","last_name"],
1> [{1,"Matt","Williamson"},
1> {2,"Matt","Williamson2"}]}.
{selected,["id","first_name","last_name"],
[{1,"Matt","Williamson"},{2,"Matt","Williamson2"}]}
2> {selected, _Columns, Results} = MysqlResult.
{selected,["id","first_name","last_name"],
[{1,"Matt","Williamson"},{2,"Matt","Williamson2"}]}
3> Content = [{result, [{id, Id}], [{first_name, [First]}, {last_name, [Last]}]} || {Id, First, Last} <- Results].
[{result,[{id,1}],
[{first_name,["Matt"]},{last_name,["Williamson"]}]},
{result,[{id,2}],
[{first_name,["Matt"]},{last_name,["Williamson2"]}]}]
4> xmerl:export_simple(, xmerl_xml).
["<?xml version=\"1.0\"?>",
[[["<","result",[[" ","id","=\"","1","\""]],">"],
[[["<","first_name",">"],["Matt"],["</","first_name",">"]],
[["<","last_name",">"],
["Williamson"],
["</","last_name",">"]]],
["</","result",">"]],
[["<","result",[[" ","id","=\"","2","\""]],">"],
[[["<","first_name",">"],["Matt"],["</","first_name",">"]],
[["<","last_name",">"],
["Williamson2"],
["</","last_name",">"]]],
["</","result",">"]]]]
5> io:format("~s", [v(-1)]).
<?xml version="1.0"?><result id="1"><first_name>Matt</first_name><last_name>Williamson</last_name></result><result id="2"><first_name>Matt</first_name><last_name>Williamson2</last_name></result>ok