this is very difficult.
there are many steps involve.
you could google for them, one after the other, once you've solved them.
1st step: get the word document structure from the file.
2nd step: what does it means to compare those structure.
3rd step: apply the above defined comparison.