7

In my website, admin uploads a .docx file. I convert the file into xml using OpenXmlPowerTools Api.

The issue is the document has some bullets in it.

• This is my bullet 1 in the document.
• This is my bullet 2 in the document.

XElement html = OpenXmlPowerTools.HtmlConverter.ConvertToHtml(wDoc, settings);
var htmlString = html.ToString();
File.WriteAllText(destFileName.FullName, htmlString, Encoding.UTF8);

Now when I open the xml file, it renders the bullets as below:-

XML Rendering

I need to read each node of XML & save in the database & reconsturct html from nodes.

Please don't ask me why so, as I am not the boss of the system.

How do I get the bullets render correctly in xml so that I can save the right html in the database?

M. Wiśnicki
  • 6,094
  • 3
  • 23
  • 28
Kgn-web
  • 7,047
  • 24
  • 95
  • 161
  • 1
    The square char is usually used then data read from a file can not be correctly converted into a given char set. This could happen if ConvertToHtml was reading the document using the wrong encoding or wDoc (don't know what that is) could be reading the file with the wrong encoding. Possibly the settings passed into ConvertToHtml has some encoding options? – Sprotty Dec 28 '16 at 09:34

2 Answers2

1

I have fixed same issue for my requirement and this working without issue so far.

In case like this you'll always have to try workaround i.e. copy this character and compare it within your input/read strings etc. if found then replace it with equivalent html encoded character. In your case it will be bullet list character "ampersandbull;" or "ampersand#8226;" .

Code should look like

listItem == "Compare with your copied character like one in your pic" ? "•" : listItem

you can find more equivalent characters at this link:

http://www.zytrax.com/tech/web/entities.html

kumar chandraketu
  • 2,232
  • 2
  • 20
  • 25
-1

Hey I don't think XML can read bullets. I'll advise you programmatically handle it. Try and debug and see what the square is being represented as and then do an if statement to find it and replace it with a code you can define so that when you return it to use it you can convert that code if found to a bullet.