I need to traverse nodes between a bookmark start and a bookmark end tag. The problem appears to break down into a tree traversal but I am having trouble pinning down the correct algorithm. The bookmark start and end elements are non-composite nodes (no children) and may appear at an arbitrary depth in the tree. Bookmark start are also not guaranteed to be a at the same depth.
If you draw the tree structure for the document I would want to examine all nodes between the start and end bookmark. I think an algorithm to traverse an unbalanced tree starting at node x and ending at node y would work. Does this sounds feasible or am I missing something.
If this is feasible could you point me in the direction of a tree traversal that could accomplish returning the nodes?
I've put together an algorithm that can easily retrieve the text of a bookmark.
How to Retrieve the Text of a Bookmark from an OpenXML WordprocessingML Document
I've also written code to replace the text of a bookmark:
Replacing Text of a Bookmark in an OpenXML WordprocessingML Document
-Eric
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With