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 30 30: def <<(element) 31: @elements << element 32: end
Produce the XMLDocument as String.
# File lib/XMLDocument.rb, line 35 35: def to_s 36: str = '' 37: @elements.each do |element| 38: str << element.to_s(0) 39: end 40: 41: str 42: end
Write the XMLDocument to the specified file.
# File lib/XMLDocument.rb, line 45 45: def write(filename) 46: f = filename == '.' ? $stdout : File.new(filename.untaint, 'w') 47: @elements.each do |element| 48: f.puts element.to_s(0) 49: end 50: f.close unless f == $stdout 51: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.