[erlang-questions] XML diff

Dmitry Kolesnikov dmkolesnikov@REDACTED
Wed Feb 1 19:53:31 CET 2012


Hello, 

even with trivial XML it would be messy, you have to supress white spaces, then take into account order of attributes and child elements, etc. 

The simples and reliable way to diff would be a construction of hash tree and then do a diff from top to down. 

- Dmitry


On Feb 1, 2012, at 6:49 PM, Wes James wrote:

> On Tue, Jan 31, 2012 at 2:45 PM, Roberto Ostinelli <roberto@REDACTED> wrote:
>> Dear list,
>> 
>> I was wandering if there is some available work done in generating XML files
>> diff, obviously in Erlang but this is a broader question.
> 
> 
> Are you going to have trivial xml files so that a simple line
> comparison would work?
> 
> -module(spxml).
> 
> -export([p/0]).
> 
> p() ->
>    {ok,F1}=file:open("f1.xml",read),
>    {ok,F2}=file:open("f2.xml",read),
>    p2(F1,F2,1).
> 
> p2(F1,F2,Acc) ->
>    F1_line=file:read_line(F1),
>    F2_line=file:read_line(F2),
>    case F1_line of
>        eof -> [];
>        _ ->
>             {ok,Res1}=F1_line,
>             {ok,Res2}=F2_line,
>            case Res1 =:= Res2 of
>                 true -> [{ok, same, Acc}|p2(F1,F2,Acc+1)];
>                 false -> [{ok, diff, Acc}|p2(F1,F2,Acc+1)]
>            end
>    end.
> 
> If not you, working with some of these ideas might:
> 
> http://erlang.2086793.n4.nabble.com/Compare-XML-string-td2268027.html
> 
> Regarding read_line, its odd that it returns a tuple until eof is
> reached.  Shouldn't it return {ok, eof}?
> 
> -wes
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list