We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Selecting text between two tags and put it into new document

I need to select the text between two tags in a document

e.g.

<#introduction> text here

and insert it into a newly created document.

Can anyone help me with this?

Thanks

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

Thanks for your inquiry. If you need to select text only then you can use Replace evaluator to achieve this. Please see the following code:

public void Test167()

{

//Open document

Document doc = new Document(@"Test167\in.doc");

//Create regex

Regex regexFindPlaceholder = new Regex(@"<\#introduction>(?.*)");

//find and replace

doc.Range.Replace(regexFindPlaceholder, new ReplaceEvaluator(ReplaceEvalGetValue), false);

}

ReplaceAction ReplaceEvalGetValue(object sender, ReplaceEvaluatorArgs e)

{

string value = e.Match.Groups["value"].Value;

return ReplaceAction.Skip;

}

But I don’t think that using tags in the word document is a good idea. I think using bookmarks is most useful. Please see the following link; maybe information provided there could be useful for you.

Best regards.