Erlang中的XML转换
我有以下XML:Erlang中的XML转换,xml,erlang,transform,Xml,Erlang,Transform,我有以下XML: <test> <something name="test"> <todo>Something is here!</todo> </something> <mytag id="myID">!!!!</mytag> <todo>Hello, world</todo> </test> 有什么标准的方法来实现它吗?我知
<test>
<something name="test">
<todo>Something is here!</todo>
</something>
<mytag id="myID">!!!!</mytag>
<todo>Hello, world</todo>
</test>
有什么标准的方法来实现它吗?我知道这是XML转换的一种Erlang方式。但它不能用来解决我的问题
我只使用Xmerl获得了**我的新字符串在这里**
。我的代码:
{ RootEl, _Rest } = xmerl_scan:string(Template),
[Match|_] = xmerl_xpath:string("//*[@id='myID']", RootEl),
% Pack new content to the container
Result = Match#xmlElement { content="**MY NEW STRING IS HERE**" }
只有非标准库(和其他库)才有可能吗?我从未使用过那个库,但我认为xmerl_lib:mapxml/2可能是您想要的。您尝试过这个库吗?它可以提供一种非常灵活的方式。非常感谢。这才是我真正想要的。
{ RootEl, _Rest } = xmerl_scan:string(Template),
[Match|_] = xmerl_xpath:string("//*[@id='myID']", RootEl),
% Pack new content to the container
Result = Match#xmlElement { content="**MY NEW STRING IS HERE**" }