Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: brynary/webrat
...
head fork: indirect/webrat
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/webrat/core/xml.rb
15 lib/webrat/core/xml.rb
View
@@ -6,14 +6,17 @@ module XML #:nodoc:
def self.document(stringlike) #:nodoc:
return stringlike.dom if stringlike.respond_to?(:dom)
- if Nokogiri::HTML::Document === stringlike
- stringlike
- elsif Nokogiri::XML::NodeSet === stringlike
+ case stringlike
+ when Nokogiri::HTML::Document, Nokogiri::XML::NodeSet
stringlike
- elsif stringlike.respond_to?(:body)
- Nokogiri::HTML(stringlike.body.to_s)
else
- Nokogiri::HTML(stringlike.to_s)
+ stringlike = stringlike.body if stringlike.respond_to?(:body)
+
+ if stringlike.to_s =~ /\<\?xml/
+ Nokogiri::XML(stringlike.to_s)
+ else
+ Nokogiri::HTML(stringlike.to_s)
+ end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.