Skip to content

Commit

Permalink
Rename data -> xml
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 16, 2010
1 parent 89c50f9 commit 91fb29b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions lib/multi_xml/parsers/libxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ module Libxml #:nodoc:
extend self

# Parse an XML Document string or IO into a simple hash using libxml.
# data::
# xml::
# XML Document string or IO to parse
def parse(data)
if !data.respond_to?(:read)
data = StringIO.new(data || '')
def parse(xml)
if !xml.respond_to?(:read)
xml = StringIO.new(xml || '')
end

char = data.getc
char = xml.getc
if char.nil?
{}
else
data.ungetc(char)
LibXML::XML::Parser.io(data).parse.to_hash
xml.ungetc(char)
LibXML::XML::Parser.io(xml).parse.to_hash
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/multi_xml/parsers/nokogiri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ module Nokogiri #:nodoc:
extend self

# Parse an XML Document string or IO into a simple hash using libxml / nokogiri.
# data::
# xml::
# XML Document string or IO to parse
def parse(data)
if !data.respond_to?(:read)
data = StringIO.new(data || '')
def parse(xml)
if !xml.respond_to?(:read)
xml = StringIO.new(xml || '')
end

char = data.getc
char = xml.getc
if char.nil?
{}
else
data.ungetc(char)
doc = ::Nokogiri::XML(data)
xml.ungetc(char)
doc = ::Nokogiri::XML(xml)
raise doc.errors.first if doc.errors.length > 0
doc.to_hash
end
Expand Down
14 changes: 7 additions & 7 deletions lib/multi_xml/parsers/rexml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ module Rexml #:nodoc:

# Parse an XML Document string or IO into a simple hash
#
# data::
# xml::
# XML Document string or IO to parse
def parse(data)
if !data.respond_to?(:read)
data = StringIO.new(data || '')
def parse(xml)
if !xml.respond_to?(:read)
xml = StringIO.new(xml || '')
end

char = data.getc
char = xml.getc
if char.nil?
{}
else
data.ungetc(char)
doc = REXML::Document.new(data)
xml.ungetc(char)
doc = REXML::Document.new(xml)

if doc.root
merge_element!({}, doc.root)
Expand Down

0 comments on commit 91fb29b

Please sign in to comment.