We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

InsertXHTML error: The 'img' start tag on line 1 position 95 does not match the end tag of 'p'.

I am trying to insert HTML that has an image embedded in it, the image is about 86 K

HTML looks something like:

<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmwAAAHvCAYAAADpWYPOAAAAAXNSR0I..........mCC"></p>

And I get this error:

  Message=DocIO support only welformatted xhtml
The 'img' start tag on line 1 position 95 does not match the end tag of 'p'. Line 1, position 86886.

This is the C# code I use:

        public static void MergeFieldEvent(object sender, MergeFieldEventArgs args)
            if (args.FieldName.Equals("Appendix"))
                WParagraph paragraph = args.CurrentMergeField.OwnerParagraph;
                int paraIndex = paragraph.OwnerTextBody.ChildEntities.IndexOf(paragraph);
                int paraItemIndex = paragraph.ChildEntities.IndexOf(args.CurrentMergeField);

                string html_string = args.FieldValue.ToString();
                html_string = html_string.Replace("<br>", "<br />");

                paragraph.OwnerTextBody.InsertXHTML(html_string, paraIndex, paraItemIndex);
                args.Text = string.Empty;

Can you please help solving this problem?

1 Reply

PR Poorani Rajendran Syncfusion Team October 21, 2019 01:06 AM

Hi Michael,

Thank you for contacting Syncfusion support.

Essential DocIO supports only well-formatted HTML file. While inserting HTML string, it should be in standard format (HTML is in proper XML). While analyzing the given HTML string, it is not a proper XML (there is no end tag of <img> tag). So, the exception occurs at your end.

So, to resolve this problem at your end, please modify the HTML string into standard format before inserting into the paragraph. We have modified your HTML string into standard format.

Please use the below modified HTML string:

"<p><img src=\"data: image / png;base64,iVBORw0KGgoAAAANSUhEUgAAAmwAAAHvCAYAAADpWYPOAAAAAXNSR0I..........mCC\"></img></p>” 

Please refer our UG documentation to know more about working with HTML using DocIO:

Please let us know if you have any other questions.

Poorani Rajendran

Live Chat Icon For mobile
Up arrow icon