Section numbering using xmerl:export

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Thu Aug 29 12:09:06 CEST 2002


I don't know about the xmerl details, but I think it might be risky to rely
on a implementation dependent feature... Of course, this depends on your
application's use.

The safe way would be going through the tree and numbering the nodes along
the path. I have written a small routine that will traverse a xml tree and
call a fun with every node. I think it might help you too (or others).

best regards,

%%% File    : xmerl_util.erl
%%% Author  :  <Vlad_dumitrescu@REDACTED>
%%% Description :
%%% Created : 14 Aug 2002 by  <Vlad_dumitrescu@REDACTED>


%% convert an xml doc into another
%% Fun should return a xmlXXX record, or a list of such records

traverse(#xmlElement{content=C}=E, Fun) ->
    C1 = lists:flatten(traverse(C, Fun)),
traverse(List, Fun) when list(List) ->
    AFun = fun(E) -> traverse(E, Fun) end,
    lists:map(AFun, List);
traverse(E, _Fun) ->

More information about the erlang-questions mailing list