Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <root>
- <!--blahblah-->
- <child/>
- </root>
- Nokogiri::XML::Builder.new do |xml|
- xml.root {
- xml.comment('blahblah')
- xml.child
- }
- end
- <root>
- <comment>blahblah</comment>
- <child/>
- </root>
- require 'nokogiri'
- xml = Nokogiri::XML::Builder.new do |xml|
- xml.root {
- xml << '<!--blahblah-->'
- xml.child
- }
- end
- puts xml.doc.root.to_xml
- #=> <root>
- #=> <!--blahblah-->
- #=> <child/>
- #=> </root>
- class Nokogiri::XML::Builder
- def comment(string)
- insert Nokogiri::XML::Comment.new( doc, string.to_s )
- end
- end
- xml << "<comment>#{comment}</comment>"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement