I have a method that return a Hash and then I write the entries of hash in xml file. Iwant to convert this Hash to an object to store the entry and then write it to xml file... My current code is like this
def entry(city)
{
:loc => ActionController::Integration::Session.new.url_for(:controller => cities , :action => show , :city_name => city.name, :host => @country_host.value),
:changefreq => 0.8,
:priority => monthly ,
:lastmod => city.updated_at
}
end
书写字——录入方法在我的撰稿人栏目中写明该条目为xml文档。
def write_entry(entry)
url = Nokogiri::XML::Node.new( "url" , @xml_document )
%w{loc changefreq priority lastmod}.each do |node|
url << Nokogiri::XML::Node.new( node, @xml_document ).tap do |n|
n.content = entry[ node.to_sym ]
end
end
url.to_xml
end
增 编