Only with `enum xmldata = import("file.xml");`, but you have to pass the -J switch and a directory path for the location of the file. E.g.: module test; enum xmldata = import("file.xml"); void parse(string data)() { } void main() { parse!(xmldata)(); } $ dmd -J. test.d "." is short for the current dir of course.