Obtaining specific childnodes from a Bookmark

Hello,

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)
    myFieldNodeCollections.Add(temp)
    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?

Ewald

Hi

Thanks for your request. I think, you can easily achieve what you need using DocumentVisitor:
https://reference.aspose.com/words/net/aspose.words/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.

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

Thanks!

Ewald