I\'ve created an XML editor and I\'m stuck at the last phase: adding undo/redo functionality.
I\'ve only got to add undo/redo for when users add elements, attributes
You have to define undo(), redo() operations along with execute() in Command interface itself.
example:
interface Command {
    void execute() ;
    void undo() ;
    void redo() ;
}
Define a State in your ConcreteCommand class. Depending on current State after execute() method, you have to decide whether command should be added to Undo Stack or Redo Stack and take decision accordingly.
Have a look at this undo-redo command article for better understanding.