I'm trying to delete all CTMarkup of a .docx file.
I already managed to rename all CTBookmarks of a docx with a visitor using TraversalUtil, and I was wondering if I could write a visitor that would delete elements (instead of modifying them).
How would you do that?
My first idea was to write this visitor, but I'm a bit stuck on how to do it the clean way :
- Code: Select all
public final class DeleteCTMarkupsVisitor extends TraversalUtilVisitor<CTMarkup> {
public DeleteCTMarkupsVisitor() {
super();
}
@Override
public void apply(CTMarkup markup) {
parent = markup.getParent(); // => Would give me the direct parent... Is that clean ?
// Then I would iterate over the parent's elements, find the markup and delete it...
}
}
Thanks!