Skip to content

Instantly share code, notes, and snippets.

@wader
Created March 21, 2014 15:00
Show Gist options
  • Save wader/9688134 to your computer and use it in GitHub Desktop.
Save wader/9688134 to your computer and use it in GitHub Desktop.
Ugly REXML::UndefinedNamespaceException workaround
require "rexml/document"
# in this case monkey patch to be able to read Inkscape "plain svg" files
# make the namespace stack start out to have inkscape: and sodipodi:
module REXML
module Parsers
class BaseParser
alias_method :old_stream, :stream=
def stream=(source)
old_stream(source)
@nsstack.unshift(Set.new(["inkscape", "sodipodi"]))
end
end
end
end
REXML::Document.new(File.read(ARGV[0])).write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment