我使用Nokogiri生成XML:
Nokogiri::XML::Builder.new do |xml|
xml['nitf'].nitf('xmlns:nitf' => 'bar') {
// some nodes here
xml.body {
xml.head {
//some nodes here
}
}
}
end
输出
<nitf:nitf xmlns:nitf="http://iptc.org/std/NITF/2006-10-18/">
// some nodes here
<nitf:body>
<nitf:head>
// some nodes here
</nitf:head>
</nitf:body>
</nitf:nitf>
但我需要<nitf:body.head>
代替<nitf:head>
。如何实现这样的结果?
答案 0 :(得分:1)
使用#send
:
xml.body {
xml.send('body.head') {
...
}
}
<nitf:body>
<nitf:body.head>
...
</nitf:body.head>
</nitf:body>