thể trùng lặp:
Print an XML document without the XML header line at the topLàm cách nào để tạo XML bằng Nokogiri mà không có "<? Xml version = ..."?
Tôi có một vấn đề với Nokogiri :: XML :: Builder. Tôi tạo ra XML wth mã này:
builder = Nokogiri::XML::Builder.new do
request {
data '1'
}
end
Và kết quả là:
<?xml version="1.0" encoding="UTF-8"?><request><data>1</data></request>
Làm thế nào tôi có thể loại bỏ:
<?xml version="1.0" encoding="UTF-8"?>
từ XML của tôi?
nó gây lỗi (Tài liệu đã có một nút gốc). Nhưng builder.parent.root.to_s thì không. Cảm tạ. Bạn làm cho tôi điều đúng cách) – mibon
Nên là 'builder.doc.root.to_xml' (hoặc' to_s'). – Phrogz