读取 HTML 文档的任务是读取 DOM 模型中的分层数据结构的任务。这意味着了解每个单独的 HTML 数据元素的格式,包括其所有可能的子元素和属性。
我们的 Ruby 库是一个基于云的解决方案,可让您轻松打开 HTML 文件进行读写。这种分布式方法使您可以灵活地使用 Ruby 语言进行软件开发,因为所有资源密集型 HTML 文档处理都将在 Aspose 服务器上进行。您只需要获取私钥即可在 Ruby 代码中访问 Cloud API。
您可以遍历 HTML 文档的所有元素,也可以在 DOM 树中搜索特定元素。我们提供了广泛的 Ruby 函数,用于处理 HTML 文件的结构和文档节点中包含的数据。
以下代码示例将帮助您快速了解如何使用 Ruby 加载 HTML 文件并对其执行一些操作。
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
file_name= 'Input.html'
request_file_content = File.open(File.read(file_name))
upload_document_request = UploadFileRequest.new(
file_content: request_file_content, path: file_name)
@words_api.upload_file(upload_document_request)
request_paragraph = ParagraphInsert.new(
{:Text => 'Reading and writing to the file in the cloud occurs automatically.'})
insert_paragraph_request = InsertParagraphRequest.new(
name: file_name, paragraph: request_paragraph)
@words_api.insert_paragraph(insert_paragraph_request)
download_document_request = DownloadFileRequest.new(path: file_name)
@words_api.download_file(download_document_request)
使用 RubyGems 托管服务安装 Aspose.Words Cloud SDK for Ruby 。运行 gem install aspose_words_cloud 来安装包。作为替代方案,您可以从 GitHub 手动克隆 Aspose.Words Cloud SDK for Ruby 源代码并在您的项目中使用它。请按照这些 Instructions 快速获取必要的安全凭证并访问我们的 REST API。