Disable DTDs completely
If you can't, then you should at least disable external entities and external DTDs
Disabling depends on the parser and language being used...
For PHP, you could do it with:
libxml_disable_entity_loader(true);
For more languages and info:
https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
How to handle file uploads:
https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html
ie: JSON or YAML
Automated tools:
Manual review: