Comments in REXML

J

Jari Williamsson

How do I add a XML comment between 2 element nodes in REXML? I've read
the documentation over and over, but I just can't find out...


Best regards,

Jari Williamsson
 
M

Mike Cargal

require "rexml/document"

doc = REXML::Document.new('<root/>')

doc.root << REXML::Element.new('elem1')
doc.root << REXML::Comment.new('this is a comment')

res = doc.to_s # => "<root><elem1/><!--this is a comment--></root>"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,117
Latest member
Matilda564
Top