读取 HTML 文档的任务是读取 DOM 模型中的分层数据结构的任务。这意味着了解每个单独的 HTML 数据元素的格式,包括其所有可能的子元素和属性。
我们的 C++ 库是一个基于云的解决方案,可让您轻松打开 HTML 文件进行读写。这种分布式方法使您可以灵活地使用 C++ 语言进行软件开发,因为所有资源密集型 HTML 文档处理都将在 Aspose 服务器上进行。您只需要获取私钥即可在 C++ 代码中访问 Cloud API。
您可以遍历 HTML 文档的所有元素,也可以在 DOM 树中搜索特定元素。我们提供了广泛的 C++ 函数,用于处理 HTML 文件的结构和文档节点中包含的数据。
以下代码示例将帮助您快速了解如何使用 C++ 加载 HTML 文件并对其执行一些操作。
using namespace aspose::words::cloud;
auto config = std::make_shared<ApiConfiguration>(L"####-####-####-####-####",
L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);
std::wstring fileName = L"Input.html";
auto requestFileContent = std::shared_ptr<std::istream>(
new std::ifstream(
std::filesystem::path(getFileTextUtf16(fileName)), std::istream::binary));
std::shared_ptr<requests::UploadFileRequest> uploadDocumentRequest(
new requests::UploadFileRequest(
requestFileContent, std::make_shared<std::wstring>(fileName)
)
);
wordsApi->uploadFile(uploadDocumentRequest);
auto requestParagraph = std::make_shared<aspose::words::cloud::models::ParagraphInsert>();
requestParagraph->setText(std::make_shared<std::wstring>(
L"Reading and writing to the file in the cloud occurs automatically."));
std::shared_ptr<requests::InsertParagraphRequest> insertParagraphRequest(
new requests::InsertParagraphRequest(
std::make_shared<std::wstring>(fileName), requestParagraph
)
);
wordsApi->insertParagraph(insertParagraphRequest);
std::shared_ptr<requests::DownloadFileRequest> downloadDocumentRequest(
new requests::DownloadFileRequest(
std::make_shared<std::wstring>(fileName)
)
);
wordsApi->downloadFile(downloadDocumentRequest);
从 GitHub 克隆 Aspose.Words Cloud SDK for C++ 源代码。您可以在 "How to use the SDK" 部分找到有关构建和配置 SDK 的详细信息。
要快速获取必要的安全凭证并访问我们的 REST API,请按照文档中的这些 Instructions 进行操作。
请参阅 Repository Documentation 以查看详细信息。