Step2: Trying to insert same tag single or muliple time based on dynamic count inside document in same location which is not possible currently im trying to find bookmark added in previous step and inserted in tags but in is inserted in start of document.
We already shared the code example with you in your other thread. Please check the following code example. This code example does not remove the inserted bookmarks from the document. You can use these bookmarks to insert the content. You just need to move the cursor to the bookmark and insert the desired content. We suggest you please read the following articles. Navigation with Cursor Working with Bookmarks
Please check attchemnt I am finding bookmark and replacing but it is inserting on top of document. tags inserted order also on reverse. Please helpInsertusingBookMark.zip (71.1 KB)
In your code example, you are inserting the start and end tag again into document. We suggest you please do not delete the tags while deleting the content between them. To achieve this, you need to insert BookmarkStart node after start tag and BookmarkEnd node before end tag.
I have to achieve three case :
Input : I will get dynamic tag count and one input document
Example
For Tag ABC dynamic count is 2
Finding in input document $abcstart{ }abcend$$$ and get foundcount
case 1: if dynamiccount and found count is same no need to delete tags and i can proceed deleting insert tags and rewrite with someother text
case 2: if dynamiccount > foundcount i have to insert tags based on dynamiccount
case 3: if dynamiccount < foundcount i have to delete tags based on dynamiccount
Please ZIP and attach your input and expected output documents for all three cases. We will investigate the cases and guide your according to your requirement.
Case 1:
if dynamiccount and found count is same no need to delete tags and i can proceed deleting insert tags and rewrite with someother text
So Give input tagcount as 4 then will get same count in document so just to delete tags data Case1.zip (30.3 KB)
Case 2: if dynamiccount > foundcount i have to insert tags based on dynamiccount
So Give input tagcount as 5 then will get lesser count in document so just to Insert tags data Case2.zip (30.3 KB)
Case 3: if dynamiccount > foundcount i have to insert tags based on dynamiccount
So Give input tagcount as 3 then will get greater count in document so just to delete tags data Case3.zip (30.3 KB)
Please use the same code to find and insert bookmark and delete the content. In this case, please insert the BookmarkStart Node after the start tag and insert BookmarkEnd node before the end tag.
In this case, please use the same approach of ‘Case 1’. After deleting the content between tags, move the cursor to desired location and insert new tags according to dynamic count.
I think, it is if dynamiccount < foundcount.
You can use the same approach of ‘Case 1’. You need to to use Range.Replace method to replace the tags with empty string. This will remove the tags from the document. If you want to add some tags, please move the cursor to desired location and add number of tags according to your requirement.