Introducing the pxrowx gem
require 'pxrowx'
txt =<<EOF
heading: fun 1
when:
priority:
planned_duration: 22
heading: fun 2
when: monday
priority: 3
planned_duration: 33
heading: fun 20
when:
priority:
planned_duration:
heading: fun 30
when:
priority:
planned_duration:
EOF
pr = PxRowX.new(txt)
puts pr.to_xml pretty: true
Output:
<?xml version='1.0' encoding='UTF-8'?> <items> <item> <summary> <heading>fun 1</heading> <when/> <priority/> <planned_duration>22</planned_duration> </summary> <records> <item> <summary> <heading>fun 2</heading> <when>monday</when> <priority>3</priority> <planned_duration>33</planned_duration> </summary> </item> </records> </item> <item> <summary> <heading>fun 20</heading> <when/> <priority/> <planned_duration/> </summary> </item> <item> <summary> <heading>fun 30</heading> <when/> <priority/> <planned_duration/> </summary> </item> </items>
Resources
pxrowx gem polyrex rowx