module OEmbed::Formatter::XML::Backends::REXML
Use the REXML
library, part of the standard library, to parse XML
values.
Public Instance Methods
decode(xml)
click to toggle source
Parses an XML
string or IO and convert it into an object
# File lib/oembed/formatter/xml/backends/rexml.rb, line 13 def decode(xml) if !xml.respond_to?(:read) xml = StringIO.new(xml) end obj = {} doc = ::REXML::Document.new(xml) doc.elements[1].elements.each do |el| obj[el.name] = el.text end obj rescue case $! when parse_error raise $! else raise parse_error, "Couldn't parse the given document." end end
decode_fail_msg()
click to toggle source
# File lib/oembed/formatter/xml/backends/rexml.rb, line 32 def decode_fail_msg "The version of the REXML library you have installed isn't parsing XML like ruby-oembed expected." end
parse_error()
click to toggle source
# File lib/oembed/formatter/xml/backends/rexml.rb, line 36 def parse_error ::REXML::ParseException end