Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/XML-DOM-serialization/Ruby/xml-dom-serialization.rb
Normal file
12
Task/XML-DOM-serialization/Ruby/xml-dom-serialization.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
require("rexml/document")
|
||||
include REXML
|
||||
(doc = Document.new) << XMLDecl.new
|
||||
root = doc.add_element('root')
|
||||
element = root.add_element('element')
|
||||
element.add_text('Some text here')
|
||||
|
||||
# save to a string
|
||||
# (the first argument to write() needs an object that understands "<<")
|
||||
serialized = String.new
|
||||
doc.write(serialized, 4)
|
||||
puts serialized
|
||||
Loading…
Add table
Add a link
Reference in a new issue