Obtaining specific childnodes from a Bookmark


I need to process mergefields within specific bookmarks.
If I can get the FieldStart nodes that are between the start and End bookmark nodes, that would be perfect.
Given an approach I used to get all the fieldStarts from the document:

doc.GetChildNodes(NodeType.FieldStart, True)

I initially tried something like

Dim myNode As Node = myBookmark.BookmarkStart
While Not (myNode.NodeType = NodeType.BookmarkEnd)
    Dim temp As NodeCollection
    temp = myNode.GetChildNodes(NodeType.FieldStart, True)
    myNode = myNode.NextSibling
End While

But “GetChildNodes” is regretfully only available on the document node itself.

Is there another way to get the FieldStart nodes I need?



Thanks for your request. I think, you can easily achieve what you need using DocumentVisitor:
Just start collection FieldStart nodes when you visit BookmarkStart of the appropriate bookmark and finish collection when you visit it’s BookmarkEnd.
Please let me know if you need more assistance, I will be glad to help you.
Best regards.

That indeed seems to fulfill my needs in a nice and clean way.