I'm having a little problem here. When i build a DOM from an XML input, i want to disable automatic entity expansion.

There is a boolean you can set using DOM (DocumentBuilderFactory), but that does not work. I believe it has something to do with the fact that DOM uses SAX.

Is there a way to disable the entity expansion?

Another option is using a custom DTD with custom entity definitions. How can i override the DTD from the DOCTYPE before parsing?