Read DMN xml through java


I am working with DMN file to extracting required data from it. I have worked to get input data from DMN file (xml data manually I have copy paste in .txt file and used) through java code as written like below.

public List<String> data() {
		List<String> val = new ArrayList<String>();
		modelclass dtls = new modelclass();
		String variables;
		try {
			File file = new File("C:/test/model_test/DMNtestfile.xml");
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			DocumentBuilder db = dbf.newDocumentBuilder();
			Document doc = db.parse(file);

			NodeList nodeList = doc.getElementsByTagName("inputExpression");
			for (int i = 0; i < nodeList.getLength(); ++i) {
				Node node = nodeList.item(i);
				if (node.getNodeType() == Node.ELEMENT_NODE) {
					Element tElement = (Element)node;
					variables = tElement.getElementsByTagName("text").item(0).getTextContent();


		catch (Exception e) {
		return val;

But now I want to directly read the DMN xml from java code instead of .txt file.

Can anyone help me on this?

Hi @Junaka ,

the Dmn-class helps you to read and write DMNModelInstances. In case you have an xml file, you can use DMN.readModelFromFile.
Alternatively if you like to read from a deployed DMN model, there is the option to load it via the RepositoryService using RepositoryService#getDmnModelInstance.

Kind regards

1 Like