How I added a hyperlink for each tag on each Snippets page

require 'dynarex'
require 'open-uri'

dx = Dynarex.new 'http://www.jamesrobertson.eu/snippets/dynarex.xml'
localbase = '/home/james/jamesrobertson.eu/'

err_report = []

dx.all.each do |entry|

  begin

    url = entry.url

    puts 'url: ' + url.inspect

    relative_url = url[/^https?:\/\/\w+.jamesrobertson.eu\/(.*)/,1]
    next unless relative_url

    page_filepath = localbase + relative_url

    doc = Rexle.new(File.read(page_filepath))
    a = doc.at_css('#info').xpath('dd/ul/li')
    next if a.first.element 'a'

    a.each do |x|
      tag = x.text
      x.text = ''
      href = "/snippets/tags/#{tag}.xml"
      link = Rexle::Element.new('a').add_text(tag)
      link.add_attribute(:href, href)
      x.add_element link
    end
    
    File.write page_filepath, doc.xml

  rescue
    err_report << [url, $!]
  end

end

The above code was used to make the tags on each Snippets page hyperlinked.

Note: There were only 2 records added to the err_report as show below:

[["http://www.jamesrobertson.eu/snippets/2013/oct/06/using-multi-line-values-in-a-rowx-document.html,", #such file or directory @ rb_sysopen - /home/james/jamesrobertson.eu/snippets/2013/oct/06/using-multi-line-values-in-a-rowx-document.html,>], 
["http://www.jamesrobertson.eu/snippets/2012/jun/01/introducing-the-the-acronym-gem-jamesrobertson-eu.html", #]]