A docx is just a renamed zip archive with the XML data. You should be able to unzip it and use a parser to access that info directly. There are likely tools to do this for any relevant language. You can also find the official spec online with some more info.
Unfortunately, I can't get into much more detail than that as my company actively develops similar tools and I've worked on their document renderers not too long ago.
No clue on the odt stuff. I worked on the MS fidelity part.