Created
September 8, 2011 14:53
-
-
Save wardbekker/1203600 to your computer and use it in GitHub Desktop.
Import XML file using Erlsom SAX parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handle_call({import, FilePath}, _From, State) -> | |
{ok, Handle} = file:open(FilePath, [read, raw, binary]), | |
Position = 0, | |
Chunk = 1024, | |
CState = {Handle, Position, Chunk}, | |
{ok, _Result, _TrailingBytes} = | |
erlsom:parse_sax( | |
<<>>, | |
undefined, | |
fun(Event, _Acc) -> sax_event(Event) end, | |
[{continuation_function, fun continue_file/2, CState}] | |
), | |
file:close(Handle), | |
Reply = ok, | |
{reply, Reply, State}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment