This class provides a rather simple XML document generator. It provides basic features to create a tree of XMLElements and to generate a XML String or file. It’s much less powerful than REXML but provides a more efficient API to create XMLDocuments with lots of attributes.
Add a top-level XMLElement.
# File lib/XMLDocument.rb, line 29 29: def <<(element) 30: @elements << element 31: end
Produce the XMLDocument as String.
# File lib/XMLDocument.rb, line 34 34: def to_s 35: str = '' 36: @elements.each do |element| 37: str << element.to_s(0) 38: end 39: 40: str 41: end
Write the XMLDocument to the specified file.
# File lib/XMLDocument.rb, line 44 44: def write(filename) 45: f = filename == '.' ? $stdout : File.new(filename.untaint, 'w') 46: @elements.each do |element| 47: f.puts element.to_s(0) 48: end 49: f.close unless f == $stdout 50: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.