I want to pars a docx file with docx4j library.
I need to detect org.docx4j.wml.instrText objects but actually it returns org.docx4j.wml.Text instead of org.docx4j.wml.instrText.
I found a solution that was working with older version of this library here:
Actually this solution:
((javax.xml.bind.JAXBElement)((org.docx4j.wml.Text) o).getParent()).getName().getLocalPart()
But with the latest update it does not work. Could you please tell me what changes I have to make on this code?
Actually it make a type casting error that can not convert org.docx4j.wml.R to JAXBElement.
Thanks in advance.
The parent of the Text object, given by:
((org.docx4j.wml.Text) o).getParent()
is, as the error says, a org.docx4j.wml.R, which you can't cast to JAXBElement.
To identify your object in this case, try:
((javax.xml.bind.JAXBElement)o).getName().getLocalPart()