You'll first have to get acquainted with XXE native Document Object Model (DOM) before attempting to develop any advanced command in Java™. Fortunately this DOM is somewhat similar though, in our opinion, simpler, than W3C DOM.
The following sample program should give you a quick tour of XXE native DOM.