Preparing a blog page in XML format

Previously I have generated blog pages in HTML format, however I would like to modify blog pages to contain additional information. Here is some sample code to demonstrate how I would generate an XML generated blog page:

require 'martile'
require 'logger'

def html(raw_buffer, filename)
  
  begin

    buffer = Martile.new(raw_buffer).to_html
    a = buffer.strip.lines.to_a
    raw_title = a.shift.chomp

    raw_tags = a.pop[/[^>]+$/].split

    s = a.join.gsub(/(?:^\[|\s\[)[^\]]+\]\((https?:\/\/[^\s]+)/) do |x|
      next x if x[/jamesrobertson\.eu/]
      s2 = x[/https?:\/\/([^\/]+)/,1].split(/\./)
      r = s2.length >= 3 ? s2[1..-1] :  s2
      "%s [%s]" % [x, r.join('.')]
    end      

    raw_body = RDiscount.new(s).to_html

    xml = RexleBuilder.new
    a = xml.page do 
      xml.summary do
        xml.title raw_title
        xml.tags do      
          raw_tags.each do |tag|
            xml.tag tag
          end
        end
        xml.source    filename
        xml.published Time.now.strftime("%d-%m-%Y %H:%M")
      end
      xml.body raw_body
    end

    doc = Rexle.new(a)
  
  rescue
    @logger.debug "jrblog.rb: html: " + ($!).to_s
  end
  
  return doc
end

@logger = Logger.new 'foo.log'

raw_buffer =<<EOF
Fun title

Some test with no new text to reply to the answers.

fun test
EOF

filename = 'http://www.jamesrobertson.eu/pages/2014/jun/13/1542hrs.md'

doc = html(raw_buffer, filename)
puts doc.xml pretty: true


output:

<?xml version='1.0' encoding='UTF-8'?>
<page>
  <summary>
    <title>Fun title</title>
    <tags>
      <tag>fun</tag>
      <tag>test</tag>
    </tags>
    <source>http://www.jamesrobertson.eu/pages/2014/jun/13/1542hrs.md</source>
    <published>13-06-2014 18:41</published>
  </summary>
  <body><p>Some test with no new text to reply to the answers.</p>
</body>
</page>
Tags:
Source:
1855hrs.txt
Published:
13-06-2014 18:55