gpt4 book ai didi

xml - 将 Nokogiri 文档转换为 Ruby 哈希

转载 作者:数据小太阳 更新时间:2023-10-29 01:37:01 26 4
gpt4 key购买 nike

有没有一种简单的方法可以将 Nokogiri XML 文档转换为哈希?

类似于 Rails 的 Hash.from_xml

最佳答案

如果要将 Nokogiri XML 文档转换为散列,只需执行以下操作:

require 'active_support/core_ext/hash/conversions'
hash = Hash.from_xml(nokogiri_document.to_s)

关于xml - 将 Nokogiri 文档转换为 Ruby 哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1230741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com