bettio
Hello ![]()
We are trying to export a “huge” amount of data from a database using XML.
Our XML exporter service is running on a cluster and it has a limited amount of memory (e.g. 4GiB of RAM) so we cannot keep in memory the whole XML document.
Does anyone knows any good Elixir (or erlang) library which allows to stream data so we don’t have to keep in memory the whole document before writing it?
Trending in Questions
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
Hi all!
I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Hey, I know this has been discussed ad nauseum, but I couldn’t find a definitive answer or at least some consensus around this, so let me...
New
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New
Other Trending Topics
Agentic Elixir - Andrea Leopardi | ElixirConf EU 2026
https://www.youtube.com/watch?v=8ats9lzIhAo
Comments welcome! View the <span cla...
New
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #code-sync
- #exunit
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #ai
- #authentication
- #elixirconf-us
- #umbrella
- #full-time-contract
- #blog-post
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-eu
- #distillery
- #security
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
wolfiton
Maybe this search will help Google Search
This emerged GitHub - processone/fast_xml: Fast Expat based Erlang XML parsing library · GitHub
bettio
This does not help:
Fast Expat based Erlang XML parsing library. I’m looking for a writer, not a parser.
dimitarvp
I hate to bring this suffering upon you but for excellent performance you should definitely just use Erlang’s :xmerl. It’s not exactly easy to work with, ask away if you get stuck.
It does support streaming, both reading and writing, so RAM will not be a problem.
bettio
Thanks, I’ll look for it. IMHO there is a huge lack of documentation about how to use it for streaming purposes. Are you aware of any useful information?
dimitarvp
I have a few scattered links that can help you get started.
xmerlis not very intuitive for a newcomer so I see some cursing in your future.Notes on xmerl and processing XML in Erlang. This one can help you understand how can you construct
:xmerlXML nodes programmatically (as opposed to receiving them when stream-parsing a file) – and then stream them to a destination file. You’ll likely have to learn to import and use Erlang records in Elixir at some point – but mind you, this is only for reading Erlang records from Elixir, not for writing them.It’s quite simple:
Read more about it:
Two blog articles on stream-reading XML files. You’ll need these even if you only write XML:
xmerl’s docs on the various hook functions that you can pass to its processors (trust me, you’ll need some of these as well, depending on the complexity of your task):Basically,
xmerlworks by accumulating XML elements / texts / namespaces etc. in a reverse-accumulator manner (prepending elements to a list; at least that’s how it works when stream-parsing and processing-as-you-go – haven’t checked the writing functionality for that idiom), using its own in-memory representation of XML. Which you can then pass to its export functions if you want a file (or only a singular XML element serialised to a charlist).As I said before, it’s going to be a ride.
bettio
Thanks for you reply
I’m still reading and trying to understand them. Anyway most of your links are not useful for us right now, since we need to write a XML file without keeping it in memory, while I think most of your links are good for stream parsing (which is the opposite).
elcritch
You might consider keeping it simple and handle writing the opening/closing tags yourself. For example using :xmerl to format chunks of XML to binary or IO list form using
Stream.map. Then write those to a custom file stream. For the File streams, it might just be easiest to write your own in one of a few ways:Stream.map(data_stream, &xml_serialize/1) |> Stream.into(file). AlternativelyStream.transformlet’s you add start and after functions so it’d be possible to write a stream accumulator (e.g. file writer) that automatically writes the root open/close tags upon stream completion.Personally, I’d consider just using a set of EEX templates to write serializers for your data. Its really not harder to do than writing HTML, and being XML you could verify your files using a schema. Using a few recursive
to_xmlfunctions and pattern matching you could handle things like “int => <%= @val %>”.Elixir’s Stream primitives and IO List mechanisms really simplify much of this problem and library might not add too much. You’ll still have to consider the size a various child elements, and might break them into smaller sub-chunks using the above to ensure your memory usage doesn’t explode. Of course, even just writing a little library yourself with a reverse SAX style “write tag start” and “write tag end” wouldn’t take too much effort (I’d guess a few hundred lines to cover 99% of useful xml) using a Collectable stream based approach.
Best of luck!
dimitarvp
The first link talks about constructing
:xmerlstructures to then serialise to files.As already mentioned, the rest of the links are for gaining understanding in the library.
dimitarvp
BTW,
:xmerlhas that – for stream parsing and stream writing. I haven’t exercised the writing but the library functions are there.ananthakumaran
We had a similar use case the difference being we need to generate xlsx files (which is just a zip file with multiple xml files). Apparently neither google nor hex.pm seems to show this library for
xml streamhttps://github.com/activesphere/xml_stream