[erlang-questions] xmerl SAX interface

Ladislav Lenart lenartlad@REDACTED
Tue Feb 6 09:24:41 CET 2007


Willem de Jong wrote:
> Hello,
> 
> I tried to find this out as well, but I didn't find the answer either.
> I ended up implementing my own SAX parser. It is part of Erlsom (which
> you can find on Sourceforge).
> 
> Your example could be parsed as follows.
> 
> S = "<e1 xmlns='urn'>
>      <e2 a2='b'>2</e2>
>      <e3>3</e3>
>     </e1>".
> 
> C = fun(Event, State) ->
>  io:format("~p\n", [Event]),
>  State
>  end.
> 
> erlsom:sax(S, [], C).
> 
> The result:
> startDocument
> {startPrefixMapping,[],"urn"}
> {startElement,"urn","e1",[],[]}
> {ignorableWhitespace,"\n\n    "}
> {startElement,"urn","e2",[],[{attribute,"a2","a2",[],"b"}]}
> {characters,"2"}
> {endElement,"urn","e2",[]}
> {ignorableWhitespace,"\n\n    "}
> {startElement,"urn","e3",[],[]}
> {characters,"3"}
> {endElement,"urn","e3",[]}
> {ignorableWhitespace,"\n\n  "}
> {endElement,"urn","e1",[]}
> {endPrefixMapping,[]}
> endDocument
> []
> 
> Regards,
> Willem

Wow!

This is exactly what I would expect from a SAX driver!

I will definitely give it a try.

Thank you very much,

Ladislav Lenart




More information about the erlang-questions mailing list