[erlang-questions] xmerl simple form

Rapsey rapsey@REDACTED
Tue Dec 27 08:44:16 CET 2011


Turn xml structure into that simple form. Lists of tuples.


Sergej

On Mon, Dec 26, 2011 at 5:12 PM, Martin Dimitrov <mrtndimitrov@REDACTED>wrote:

> Hello Sergej,
>
> Thanks for sharing this code. I cannot find documentation for the
> xmerl_lib module? What does simplify_element/1 do?
>
> Regards,
>
> Martin
>
> On 12/26/2011 5:20 PM, Rapsey wrote:
> > I use this:
> >
> > parsexml(I,O) when is_binary(I) ->
> >     parsexml(tolist(I),O);
> > parsexml(InputXml,Opt) ->
> >     try {Xml,_} = xmerl_scan:string(InputXml,
> > [{space,normalize},{encoding,"utf-8"},{validation,off}|Opt]),
> >             strip_whitespace(xmerl_lib:simplify_element(Xml)) of
> >         Res ->
> >             Res
> >     catch
> >         error:_X ->
> >             io:format("~p", [_X]),
> >             false
> >     end.
> >
> > strip_whitespace({El,Attr,Children}) ->
> >   NChild = lists:filter(fun(X) ->
> >     case X of
> >     " " -> false;
> >     _   -> true
> >     end
> >   end,Children),
> >   Ch = lists:map(fun(X) -> strip_whitespace(X) end,NChild),
> >   {El,Attr,Ch};
> > strip_whitespace(String) ->
> >     String.
> >
> >
> >
> > Sergej
> >
> > On Mon, Dec 26, 2011 at 2:54 PM, Martin Dimitrov <mrtndimitrov@REDACTED
> >wrote:
> >
> >> Hello,
> >>
> >> There is an example in the user's guide
> >> (http://www1.erlang.org/doc/apps/xmerl/xmerl_ug.html#id58936) of how to
> >> export to XML format a structure in the so called 'simple form'.
> >> Is there a method to parse XML document to this 'simple form'?
> >>
> >> Regards,
> >>
> >> Martin
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://erlang.org/mailman/listinfo/erlang-questions
> >>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111227/6af7db94/attachment.htm>


More information about the erlang-questions mailing list