我正在使用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>
。如何取得这样的结果?
使用#send
:求解
xml.body {
xml.send('body.head') {
...
}
}
<nitf:body>
<nitf:body.head>
...
</nitf:body.head>
</nitf:body>