C#
(main code segment)
Documents? Doctor. =? New? Document ();
Doctor. LoadFromFile(" bookmark . docx ");
BookmarksNavigator? Navigator? =? New? bookmarks navigator(doc);
A navigator. MoveToBookmark(" bookmark _ 1 ");
TextBodyPart? textBodyPart? =? A navigator. GetBookmarkContent();
String? Words? =? null
foreach? (var? Articles? Are you online? textBodyPart。 Text item)
{
What if? (item? Is it? Paragraph)
{
foreach? (var? childObject? Are you online? (item? As? Paragraph). Child object)
{
What if? (childObject? Is it? Text range)
{
Words? +=? (childObject? As? TextRange)。 Text;
}
}
}
}
Console. WriteLine (text); You can also refer to the original text: C# to get Word bookmarks.