Retrieve all tasks/nodes from a process definition xml

I am looking for a way to read all the nodes or tasks using a BpmnModelInstance object. I see various methods to retrieve the details by type. Since the file can have any type and there are many types available, i am looking a generic method to list me all children of bpmn:process

I found the solution. Adding it here in case it helps someone.

ModelElementType taskType = modelInstance
.getModel()
.getType(FlowElement.class);

Collection taskInstances = modelInstance.getModelElementsByType(taskType);

taskInstances gives you all the nodes. It also included the sequenceflows. You may filter it if you dont need them.

1 Like

Thanks for adding your solution