The @external_resource module attribute is a good place to start:
You could point that at your XML file, then parse it into a module attribute:
defmodule BagOfXml do
@external_resource "path/to/some.xml"
@parsed_data SomeOtherModule.parse("path/to/some.xml")
def lookup_thing(id) do
# use @parsed_data and id to do stuff
end
end
This will call SomeOtherModule.parse at compile-time (it cannot be a function in the same file) and store the resulting data in the compiled BEAM file.
@external_resource will ensure that if the XML file changes the module will be recompiled.






















