[erlang-questions] xmerl with multiple items

Steve Vinoski vinoski@REDACTED
Mon Sep 22 16:24:34 CEST 2008


On 9/22/08, Joe Williams <joe@REDACTED> wrote:
>
>  I am working on one of the xmerl examples found at
>  http://blog.tornkvist.org/blog.yaws?id=1193209275268448 specifically,

<snip/>

>  What is the best way to fix this issue so I can have the code work for
>  one to many items?

Change the Val macro to:

-define(Val(X),
   (fun() ->
            [{N,V} || #xmlElement{name = N, content = [#xmlText{value
= V}|_]} <- X]
    end)()).

When xpath matches multiple items, this allows all matches to appear
in the result, and it still works for one match as well.

--steve



More information about the erlang-questions mailing list