Free Support Forum - aspose.com

Deleting portions of a document

I am interested in removing segments of a template document. In other words, if my document contains the following info:

{my_id}
Some title
Here is some text in the document.
{/my_id}

I would like to be able to remove all text between the {my_id} and {/my_id}.

Does anyone have some sample code that might accomplish this? Or is there some other strategy that might accomplish the same thing?

Thanks for your help.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. There is no direct way to achieve this, however, it is possible to achieve. You can try using code provided here:

http://www.aspose.com/community/forums/242811/range.replace-regex/showthread.aspx#242811

Also, if you have control over your document, you can use bookmark instead of placeholders. In case of using bookmarks, you can remove its content by simply clearing its text.

doc.Range.Bookmarks["myBookmark"].Text = "";

Best regards.