Passing arguments and parsing xml in Erlang
Howdy我仍在学习Erlang,我试图通过函数传递不止一个参数,但我遇到了麻烦。
首先,我使用xmerl.hrl解析xml。我通过命令行使用erlfile:process_xml(" filename.xml ")调用process_xml(Doc)。
1 2 | process_xml(Doc) -> makeBottom1(Doc,"yup got here"). |
从此处开始,过程调用makeBottom1传递文档和一个字符串以稍后测试输出。
1 2 | makeBottom1(E = #xmlElement{name='resource'}, Derp) ->"Got to resource"; makeBottom1(E, Derp) -> ["BURP", Derp, built_in_rules( fun makeBottom1/2 , [E, Derp] ),"-" ]. |
我希望它返回" Got to resource "的次数,但似乎永远不会触发该函数调用。
它返回的内容是:
1 | ["BURP","yup got here",[],"-"] |
我应该为我想要的功能使用其他xml解析器吗?我只是在犯一个菜鸟错误吗?
函数
要变通解决此问题,您需要更改使用
1 | built_in_rules(fun(Child) -> makeBottom1(Child, Derp) end, E) |
我们没有尝试传入Arity为2的函数并期望