在C#中使用Aspose處理HTML文檔的方法如下:
using Aspose.Words;
string html = File.ReadAllText("input.html");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(html);
doc.Save("output.docx");
Document doc = new Document("input.docx");
foreach (Run run in doc.GetChildNodes(NodeType.Run, true))
{
if (run.Text.Contains("oldText"))
{
run.Text = run.Text.Replace("oldText", "newText");
}
}
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("This is a new paragraph.");
doc.Save("output.docx");
這些是使用Aspose在C#中處理HTML文檔的基本方法。您可以根據需要進一步探索Aspose.Words庫的功能以處理更復雜的HTML文檔。