[erlang-questions] xmerl_sax_parser node information trivial problem

Jakub Zawierucha <>
Fri Dec 4 12:13:29 CET 2009


I've solved this by putting tags on stack.

JZ

Jakub Zawierucha pisze:
> Hello,
>
> I'm trying to write a simple app that will process XML file and give 
> me information about some nodes. I need to know how many attributes 
> and children nodes are avaliable in that node. I know how to obtain 
> attr count (just count Attributes) but how about children nodes ? Any 
> ideas ?
>
> i have:
>
> do_magic(Lang, Xml) ->
>    xmerl_sax_parser:stream(Xml, [
>                                  {continuation_fun, fun 
> continuationfun/1},
>                                  {event_fun, fun eventfun/3},
>                                  {event_state, {[Lang],<<>>}}
>                                 ]).
> (...)
>
> eventfun({startElement, Uri, LocalName, QualifiedName, Attrubutes}, 
> Location, {Stack, Acc}) ->
>    [Lang|_] = Stack,                 % >>>>>> How many subnodes is in 
> tag called: LocalName <<<<<<
>            {Stack, Acc}
>    end;
>
> Thanks,
> Jakub Zawierucha
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>



More information about the erlang-questions mailing list