InsertHtml Bug?

Hi,

I am having an issue with the DocumentBuilder.InsertHtml method. Consider the following call.
docBuilder.InsertHtml("<0.21 value A
>= 2.2 value B");

I would expect the result in the document to be:
<0.21 value A
>= 2.2 value B

Instead I get the following:
>= 2.2 value B

The document throws out the first line.

Any idea?

BTW - I am using Aspose Words for .NET v 5.2.2

Hi
Thanks for your request. I think this is correct behavior. “<” is recognized as open tag. You should encode your html as shown in the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(HttpUtility.HtmlEncode("<") + "0.21 value A
" + HttpUtility.HtmlEncode(">") + "= 2.2 value B");
doc.Save(@"Test005\out.doc");

Hope this helps.
Best regards.

Alexey,

The approach you descibe above is how I solved the issue. However, it seems strange to me that the Aspose component does not recognize what is a real html tag and what is just text. We are pulling data for a 1000 page document out of a database. The text has embedded html and text that has the < and > signs in it. It is slow and a pain to preprocess the data before adding it to the document. Are there any plans to upgrade this feature to consider the above? Note that if I put this text directly in a browser, it does the right thing.

Thanks!

Hi

It is not correct to use “<” and “>” in HTML. “<” and “>” should be used instead. Please see the following link.
http://www.w3schools.com/HTML/html_entities.asp
Best regards.