My Website flow.
- Authenticated user will upload docx.
- I am using
OpenXmlPowerTools
API to convert this docx to HTML - Save the file
- Save each node of the html page into database.
Database:-
tblNodeCollection
- NodeId
- Node Type (Expected values -
<p>
,<h1>
,<h3>
,<table>
) - NodeContent (Expected Value -
<p> This is p content </p>
No issues till Step #3. But I am clueless on how to save the nodes collection into the table.
I googled & found HTMLAgiiltiyPack
but don't know much about it.
using DocumentFormat.OpenXml.Packaging;
using HtmlAgilityPack;
using OpenXmlPowerTools;
namespace ExportData
{
public class ExportHandler
{
public void GenerateHTML()
{
byte[] byteArray = File.ReadAllBytes(@"d:\test.docx");
using (MemoryStream memoryStream = new MemoryStream())
{
memoryStream.Write(byteArray, 0, byteArray.Length);
using (WordprocessingDocument doc =
WordprocessingDocument.Open(memoryStream, true))
{
HtmlConverterSettings settings = new HtmlConverterSettings()
{
PageTitle = "My Page Title"
};
XElement html = HtmlConverter.ConvertToHtml(doc, settings);
File.WriteAllText(@"d:\Test.html", html.ToStringNewLineOnAttributes());
}
}
//now how do I proceed from here
}
}
Any type of help/guidance highly appreciated.
The website has lots of other stuff to do with each node. – Kgn-web Dec 16 '16 at 12:09