Introducing the RowX gem

require 'rowx'

txt =<<EOF
title: testing 123

-----------------------------
path: 1
type: date only
desc:

input:
  date: 22-Apr-2011 12:34
  entry: * * * * *

output:
  date: 2011-04-22 12:34

------------------------------

path: 2
type: date only
desc:

input:
  date: 22-Apr-2011 12:34
  entry: * * * * *

output:
  date: 2011-04-22 12:34

------------------------------

EOF



Output:

irb(main):214:0> puts xml
<?xml version='1.0' encoding='UTF-8'?>
<root>
  <summary>
    <title>testing 1 2 3</title>
  </summary>
  <item>
    <path>1</path>
    <type>date only</type>
    <desc/>
    <input>
      <item>
        <date>22-Apr-2011 12:34</date>
        <entry>* * * * *</entry>
      </item>
    </input>
    <output>
      <item>
        <date>2011-04-22 12:34</date>
      </item>
    </output>
  </item>
  <item>
    <path>2</path>
    <type>date only</type>
    <desc/>
    <input>
      <item>
        <date>22-Apr-2011 12:34</date>
        <entry>* * * * *</entry>
      </item>
    </input>
    <output>
      <item>
        <date>2011-04-22 12:34</date>
      </item>
    </output>
  </item>
</root>

The RowX gem makes it more convenient to generate XML with minimal syntax. In the above code a heredoc contains a couple of records which is then passed to the RowX Object to be converted to XML.

Notes:

Resources: