I am utilizing this new code, just found that the replace method needs a
small change to keep the node's style. After we make sure nextNode is not a
bookmarkEnd we push it to stack, so push should be done in "else stmt" not
before "if stmt".
while (bookmarkStartID != bookmarkEndID) {
nextNode = nextNode.getNextSibling();
//This line should be commented ---> nodeStack.push(nextNode);
// and the else after if should be uncommented!
if (nextNode.getNodeName().contains(Bookmark.BOOKMARK_END_TAG))
{
try {
bookmarkEndID = Integer.parseInt(
nextNode.getAttributes().getNamedItem(
Bookmark.BOOKMARK_ID_ATTR_NAME).getNodeValue());
} catch (NumberFormatException nfe) {
bookmarkEndID = bookmarkStartID;
}
}
else {
nodeStack.push(nextNode);
}
}
-----
Regards,
Hashem
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-tp5710184p5710816.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]