使用Nokogiri的XML形成

问题描述

我正在尝试使用下面显示代码创建XML文档。

我的代码如下所示:

require 'nokogiri'

builder = Nokogiri::XML::Builder.new do
    {
        action "GetApplication"
        email "[email protected]"
        password "f1467868c64f818c7b9394d85cc46d98"
        request {
            response_format "detailed"
            application_id "15544"
            render_applicant_extended_fields {
                ari_criminal_info ""
                ari_evictions_info ""
                limelyte_employment ""
                limelyte_drivers_license""
            }
        }
    }
end

req_body = builder.to_xml

但是,当我尝试将其转换为XML时,却遇到了该错误

enter image description here

如何克服此限制?任何帮助将不胜感激。

解决方法

尝试以下方法:

require 'nokogiri'

builder = Nokogiri::XML::Builder.new do
  root {
    action "GetApplication"
    email "[email protected]"
    password "f1467868c64f818c7b9394d85cc46d98"
    request {
      response_format "detailed"
      application_id "15544"
      render_applicant_extended_fields {
        ari_criminal_info ""
        ari_evictions_info ""
        limelyte_employment ""
        limelyte_drivers_license""
      }
    }
  }
end

req_body = builder.to_xml