Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word OpenXML . Traversing OpenXmlElements between bookmarks

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?

like image 864
user166244 Avatar asked Oct 14 '22 12:10

user166244


1 Answers

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

like image 57
Eric White Avatar answered Oct 20 '22 16:10

Eric White