Search code examples
xmlsaxbpmnjdom

JDOM BPMN parsing jdom


i want to parse my BPMN.xml file with JDOM. So, first of all i'm extracting data with SAX, the problem is BPMN.xml has the folowing format:

 <bpmn2:process id="process_2" name="Default Process" isExecutable="false">

which returns null when having in the .java file:

Element process=root.getChild("bpmn2:process")

i note that the element "root=document.getRootElement();" does not return null

and when i modify it to

<process id="process_2" name="Default Process" isExecutable="false">

and

Element process=root.getChild("process")

it accepts it so how to deal with that bpmn2: without deleting it?

Thank you


Solution

  • Is the namespace prefix bpmn2 declared, using a namespace declaration such as xmlns:bpmn2="http://something/"? If not, your XML isn't namespace-well-formed, which severely limits your options in processing it.

    If there is a namespace declaration, then use

    Element process=root.getChild("process", "http://something/");
    

    where the second argument is the namespace URI associated with the prefix bpmn2.