History of Idiom 104 > diff from v18 to v19
Edit summary for version 19 by ricc:
[Ruby] wrong demo
[Ruby] wrong demo
↷
Version 18
2022-04-19, 14:59:27
Version 19
2022-04-19, 15:00:22
Idiom #104 Save object into XML file
Write the contents of the object x into the file data.xml.
Idiom #104 Save object into XML file
Write the contents of the object x into the file data.xml.
Variables
x,data,xmlVariables
x,data,xmlCode
class Person
include XML::Mapping
attr_accessor :name, :surname, :age, :children
text_node :from, "@from"
text_node :name, "Name"
text_node :surname, "Surname"
def initialize(name, surname, ..)
# ...
end
end
x = Person.new(..)
x.save_to_xml.write($stdout,2) # nicely prints
x.save_to_file('data.xml')
Code
class Person
include XML::Mapping
attr_accessor :name, :surname, :age, :children
text_node :from, "@from"
text_node :name, "Name"
text_node :surname, "Surname"
def initialize(name, surname, ..)
# ...
end
end
x = Person.new(..)
x.save_to_xml.write($stdout,2) # nicely prints
x.save_to_file('data.xml')
Comments bubble
Comments bubble