<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@
 * New Features
 
   * Facebooker::User#publish_to for publishing to a Wall or News Stream
+  * Optionally parses with Nokogiri.  Just require 'nokogiri' in your app.
 
 === 1.0.13 / 2009-02-26
 </diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,14 @@
 module Facebooker
   class BeboAdapter &lt; AdapterBase
-      
+
     def canvas_server_base
       &quot;apps.bebo.com&quot;
     end
-      
+
     def api_server_base
       'apps.bebo.com'
     end
-    
+
     def api_rest_path
       &quot;/restserver.php&quot;
     end
@@ -44,9 +44,9 @@ module Facebooker
     end
     alias_method :set_profile_fbml_without_bebo_adapter, :set_profile_fbml
     alias_method :set_profile_fbml, :set_profile_fbml_with_bebo_adapter
-    
+
     private
-    
+
     BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]
 
     remove_method :collect
@@ -57,15 +57,15 @@ module Facebooker
       else
          FIELDS.reject{|field_name| !fields.empty? &amp;&amp; !fields.include?(field_name)}.join(',')
       end
-    end   
+    end
   end
-  
-  
+
+
    class PublishTemplatizedAction &lt; Parser#:nodoc:
     class &lt;&lt;self
      def process_with_bebo_adapter(data)
        if(Facebooker.is_for?(:bebo))
-       element('feed_publishTemplatizedAction_response', data).text_value
+       element('feed_publishTemplatizedAction_response', data).content
        else
          process_without_bebo_adapter(data)
        end</diff>
      <filename>lib/facebooker/adapters/bebo_adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ module Facebooker
     def initialize(session)
       @session = session
     end
-    
+
     ##
     # ** BETA ***
     # Sets a cookie on Facebook
@@ -11,32 +11,32 @@ module Facebooker
     # +name+ Name of the cookie
     # +value+ Value of the cookie
     # Optional:
-    # +expires+ Time when the cookie should expire. If not specified, the cookie never expires. 
+    # +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
     # +path+ Path relative to the application's callback URL, with which the cookie should be associated. (default value is /?
     def set_cookie(user, name, value, expires=nil, path=nil)
-      @session.post('facebook.data.setCookie', 
-        :uid =&gt; User.cast_to_facebook_id(user), 
-        :name =&gt; name, 
-        :value =&gt; value, 
-        :expires =&gt; expires, 
+      @session.post('facebook.data.setCookie',
+        :uid =&gt; User.cast_to_facebook_id(user),
+        :name =&gt; name,
+        :value =&gt; value,
+        :expires =&gt; expires,
         :path =&gt; path) {|response| response == '1'}
     end
-    
+
     ##
     # ** BETA ***
     # Gets a cookie stored on Facebook
-    # +user+	The user from whom to get the cookies.	
-    # Optional:   
+    # +user+	The user from whom to get the cookies.
+    # Optional:
     # +name+ The name of the cookie. If not specified, all the cookies for the given user get returned.
     def get_cookies(user, name=nil)
-      @cookies = @session.post( 
+      @cookies = @session.post(
         'facebook.data.getCookies', :uid =&gt; User.cast_to_facebook_id(user), :name =&gt; name) do |response|
           response.map do |hash|
             Cookie.from_hash(hash)
           end
       end
-    end   
-    
+    end
+
     ##
     # ** BETA ***
     # Gets a preference stored on Facebook
@@ -54,4 +54,4 @@ module Facebooker
       @session.post('facebook.data.setUserPreference', :pref_id=&gt;pref_id, :value=&gt;value)
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>lib/facebooker/data.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,26 +3,41 @@ require 'facebooker/session'
 module Facebooker
   class Parser
 
-    module REXMLElementExtensions
-      def text_value
-        self.children.first.to_s.strip
+    module REXMLElementExtensions # :nodoc:
+      def content
+        self.text || ''
+      end
+
+      def [] key
+        attributes[key]
+      end
+
+      def text?
+        false
+      end
+    end
+
+    module REXMLTextExtensions # :nodoc:
+      def text?
+        true
       end
     end
 
     ::REXML::Element.__send__(:include, REXMLElementExtensions)
+    ::REXML::Text.__send__(:include, REXMLTextExtensions)
 
     def self.parse(method, data)
       Errors.process(data)
       parser = Parser::PARSERS[method]
       raise &quot;Can't find a parser for '#{method}'&quot; unless parser
-      parser.process(
-        data
-      )
+      parser.process(data)
     end
 
     def self.array_of(response_element, element_name)
       values_to_return = []
-      response_element.elements.each(element_name) do |element|
+      response_element.children.each do |element|
+        next if element.text?
+        next unless element.name == element_name
         values_to_return &lt;&lt; yield(element)
       end
       values_to_return
@@ -30,7 +45,7 @@ module Facebooker
 
     def self.array_of_text_values(response_element, element_name)
       array_of(response_element, element_name) do |element|
-        element.text_value
+        element.content.strip
       end
     end
 
@@ -42,34 +57,39 @@ module Facebooker
 
     def self.element(name, data)
       data = data.body rescue data # either data or an HTTP response
-      doc = REXML::Document.new(data)
-      doc.elements.each(name) do |element|
-        return element
+      begin
+        node = Nokogiri::XML(data.strip).at(name)
+        return node if node
+      rescue # Can't parse with Nokogiri
+        doc = REXML::Document.new(data)
+        doc.elements.each(name) do |element|
+          return element
+        end
       end
       raise &quot;Element #{name} not found in #{data}&quot;
     end
 
     def self.hash_or_value_for(element)
-      if element.children.size == 1 &amp;&amp; element.children.first.kind_of?(REXML::Text)
-        element.text_value
+      if element.children.size == 1 &amp;&amp; element.children.first.text?
+        element.content.strip
       else
         hashinate(element)
       end
     end
 
     def self.hashinate(response_element)
-      response_element.children.reject{|c| c.kind_of? REXML::Text}.inject({}) do |hash, child|
+      response_element.children.reject{|c| c.text? }.inject({}) do |hash, child|
         # If the node hasn't any child, and is not a list, we want empty strings, not empty hashes,
         #   except if attributes['nil'] == true
         hash[child.name] =
-        if (child.attributes['nil'] == 'true')
+        if (child['nil'] == 'true')
           nil
-        elsif (child.children.size == 1 &amp;&amp; child.children.first.kind_of?(REXML::Text)) || (child.children.size == 0 &amp;&amp; child.attributes['list'] != 'true')
-          anonymous_field_from(child, hash) || child.text_value
-        elsif child.attributes['list'] == 'true'
-          child.children.reject{|c| c.kind_of? REXML::Text}.map { |subchild| hash_or_value_for(subchild)}
+        elsif (child.children.size == 1 &amp;&amp; child.children.first.text?) || (child.children.size == 0 &amp;&amp; child['list'] != 'true')
+          anonymous_field_from(child, hash) || child.content.strip
+        elsif child['list'] == 'true'
+          child.children.reject{|c| c.text? }.map { |subchild| hash_or_value_for(subchild)}
         else
-          child.children.reject{|c| c.kind_of? REXML::Text}.inject({}) do |subhash, subchild|
+          child.children.reject{|c| c.text? }.inject({}) do |subhash, subchild|
             subhash[subchild.name] = hash_or_value_for(subchild)
             subhash
           end
@@ -84,7 +104,7 @@ module Facebooker
 
     def self.anonymous_field_from(child, hash)
       if child.name == 'anon'
-        (hash[child.name] || []) &lt;&lt; child.text_value
+        (hash[child.name] || []) &lt;&lt; child.content.strip
       end
     end
 
@@ -98,7 +118,7 @@ module Facebooker
 
   class CreateToken &lt; Parser#:nodoc:
     def self.process(data)
-      element('auth_createToken_response', data).text_value
+      element('auth_createToken_response', data).content.strip
     end
   end
 
@@ -152,13 +172,13 @@ module Facebooker
 
   class GetLoggedInUser &lt; Parser#:nodoc:
     def self.process(data)
-      Integer(element('users_getLoggedInUser_response', data).text_value)
+      Integer(element('users_getLoggedInUser_response', data).content.strip)
     end
   end
 
   class PagesIsAdmin &lt; Parser#:nodoc:
     def self.process(data)
-      element('pages_isAdmin_response', data).text_value == '1'
+      element('pages_isAdmin_response', data).content.strip == '1'
     end
   end
 
@@ -170,25 +190,25 @@ module Facebooker
 
   class PagesIsFan &lt; Parser#:nodoc:
     def self.process(data)
-      element('pages_isFan_response', data).text_value == '1'
+      element('pages_isFan_response', data).content.strip == '1'
     end
   end
 
   class PublishStoryToUser &lt; Parser#:nodoc:
     def self.process(data)
-      element('feed_publishStoryToUser_response', data).text_value
+      element('feed_publishStoryToUser_response', data).content.strip
     end
   end
 
   class StreamPublish &lt; Parser#:nodoc:
     def self.process(data)
-      element('stream_publish_response', data).text_value
+      element('stream_publish_response', data).content.strip
     end
   end
 
   class RegisterTemplateBundle &lt; Parser#:nodoc:
     def self.process(data)
-      element('feed_registerTemplateBundle_response', data).text_value.to_i
+      element('feed_registerTemplateBundle_response', data).content.to_i
     end
   end
 
@@ -200,55 +220,55 @@ module Facebooker
 
   class DeactivateTemplateBundleByID &lt; Parser#:nodoc:
     def self.process(data)
-      element('feed_deactivateTemplateBundleByID_response', data).text_value == '1'
+      element('feed_deactivateTemplateBundleByID_response', data).content.strip == '1'
     end
   end
 
   class PublishUserAction &lt; Parser#:nodoc:
     def self.process(data)
-      element('feed_publishUserAction_response', data).children[1].text_value == &quot;1&quot;
+      element('feed_publishUserAction_response', data).children[1].content.strip == &quot;1&quot;
     end
   end
 
   class PublishActionOfUser &lt; Parser#:nodoc:
     def self.process(data)
-      element('feed_publishActionOfUser_response', data).text_value
+      element('feed_publishActionOfUser_response', data).content.strip
     end
   end
 
   class PublishTemplatizedAction &lt; Parser#:nodoc:
     def self.process(data)
-      element('feed_publishTemplatizedAction_response', data).children[1].text_value
+      element('feed_publishTemplatizedAction_response', data).children[1].content.strip
     end
   end
 
   class SetAppProperties &lt; Parser#:nodoc:
     def self.process(data)
-      element('admin_setAppProperties_response', data).text_value
+      element('admin_setAppProperties_response', data).content.strip
     end
   end
 
   class GetAppProperties &lt; Parser#:nodoc:
     def self.process(data)
-      element('admin_getAppProperties_response', data).text_value
+      element('admin_getAppProperties_response', data).content.strip
     end
   end
 
   class SetRestrictionInfo &lt; Parser#:nodoc:
     def self.process(data)
-      element('admin_setRestrictionInfo_response', data).text_value
+      element('admin_setRestrictionInfo_response', data).content.strip
     end
   end
 
   class GetRestrictionInfo &lt; Parser#:nodoc:
     def self.process(data)
-      element('admin_getRestrictionInfo_response', data).text_value
+      element('admin_getRestrictionInfo_response', data).content.strip
     end
   end
 
   class GetAllocation &lt; Parser#:nodoc:
     def self.process(data)
-      element('admin_getAllocation_response', data).text_value
+      element('admin_getAllocation_response', data).content.strip
     end
   end
 
@@ -289,13 +309,13 @@ module Facebooker
 
   class NotificationsSend &lt; Parser#:nodoc:
     def self.process(data)
-      element('notifications_send_response', data).text_value
+      element('notifications_send_response', data).content.strip
     end
   end
 
   class NotificationsSendEmail &lt; Parser#:nodoc:
     def self.process(data)
-      element('notifications_sendEmail_response', data).text_value
+      element('notifications_sendEmail_response', data).content.strip
     end
   end
 
@@ -343,19 +363,19 @@ module Facebooker
 
   class SendRequest &lt; Parser#:nodoc:
     def self.process(data)
-      element('notifications_sendRequest_response', data).text_value
+      element('notifications_sendRequest_response', data).content.strip
     end
   end
 
   class ProfileFBML &lt; Parser#:nodoc:
     def self.process(data)
-      element('profile_getFBML_response', data).text_value
+      element('profile_getFBML_response', data).content.strip
     end
   end
 
   class ProfileFBMLSet &lt; Parser#:nodoc:
     def self.process(data)
-      element('profile_setFBML_response', data).text_value
+      element('profile_setFBML_response', data).content.strip
     end
   end
 
@@ -367,39 +387,39 @@ module Facebooker
 
   class ProfileInfoSet &lt; Parser#:nodoc:
     def self.process(data)
-      element('profile_setInfo_response', data).text_value
+      element('profile_setInfo_response', data).content.strip
     end
   end
 
   class FqlQuery &lt; Parser#nodoc
     def self.process(data)
       root = element('fql_query_response', data)
-      first_child = root.children.reject{|c| c.kind_of?(REXML::Text)}.first
+      first_child = root.children.reject{|c| c.text? }.first
       first_child.nil? ? [] : [first_child.name, array_of_hashes(root, first_child.name)]
     end
   end
 
   class SetRefHandle &lt; Parser#:nodoc:
     def self.process(data)
-      element('fbml_setRefHandle_response', data).text_value
+      element('fbml_setRefHandle_response', data).content.strip
     end
   end
 
   class RefreshRefURL &lt; Parser#:nodoc:
     def self.process(data)
-      element('fbml_refreshRefUrl_response', data).text_value
+      element('fbml_refreshRefUrl_response', data).content.strip
     end
   end
 
   class RefreshImgSrc &lt; Parser#:nodoc:
     def self.process(data)
-      element('fbml_refreshImgSrc_response', data).text_value
+      element('fbml_refreshImgSrc_response', data).content.strip
     end
   end
 
   class SetCookie &lt; Parser#:nodoc:
     def self.process(data)
-      element('data_setCookie_response', data).text_value
+      element('data_setCookie_response', data).content.strip
     end
   end
 
@@ -469,37 +489,37 @@ module Facebooker
 
   class SetStatus &lt; Parser
     def self.process(data)
-      element('users_setStatus_response',data).text_value == '1'
+      element('users_setStatus_response',data).content.strip == '1'
     end
   end
 
   class GetPreference &lt; Parser#:nodoc:
     def self.process(data)
-      element('data_getUserPreference_response', data).text_value
+      element('data_getUserPreference_response', data).content.strip
     end
   end
 
   class SetPreference &lt; Parser#:nodoc:
     def self.process(data)
-      element('data_setUserPreference_response', data).text_value
+      element('data_setUserPreference_response', data).content.strip
     end
   end
 
   class UserHasPermission &lt; Parser
     def self.process(data)
-      element('users_hasAppPermission_response', data).text_value
+      element('users_hasAppPermission_response', data).content.strip
     end
   end
 
   class SmsSend &lt; Parser#:nodoc:
     def self.process(data)
-      element('sms_send_response', data).text_value == '0'
+      element('sms_send_response', data).content.strip == '0'
     end
   end
 
   class SmsCanSend &lt; Parser#:nodoc:
     def self.process(data)
-      element('sms_canSend_response', data).text_value
+      element('sms_canSend_response', data).content.strip
     end
   end
 </diff>
      <filename>lib/facebooker/parser.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,46 +6,46 @@ class Facebooker::DataTest &lt; Test::Unit::TestCase
     #make sure we use net::http since that's what the tests expect
     Facebooker.use_curl=false
   end
-  
+
   def test_can_ask_facebook_to_set_a_cookies
     expect_http_posts_with_responses(example_set_cookie_xml)
     assert(@session.data.set_cookie(12345, 'name', 'value'))
   end
-    
+
   def test_can_ask_facebook_to_get_cookies
     expect_http_posts_with_responses(example_get_cookies_xml)
     assert(@session.data.get_cookies(12345))
   end
-  
+
   def test_can_get_cookies_for_user
     mock_http = establish_session
     mock_http.should_receive(:post_form).and_return(example_get_cookies_xml).once.ordered(:posts)
-    cookies = @session.data.get_cookies(508508326)    
+    cookies = @session.data.get_cookies(508508326)
     assert_equal 'Foo', cookies.first.name
     assert_equal 'Bar', cookies.first.value
   end
-  
+
   def test_can_ask_facebook_to_set_a_preference
     expect_http_posts_with_responses(example_set_preference_xml)
     assert(@session.data.set_preference(0, 'hello'))
   end
-    
+
   def test_can_ask_facebook_to_get_preference
     expect_http_posts_with_responses(example_get_preference_xml)
     assert(@session.data.get_preference(0))
   end
-  
+
   def test_can_get_preference
     mock_http = establish_session
     mock_http.should_receive(:post_form).and_return(example_get_preference_xml).once.ordered(:posts)
-    assert_equal 'hello', @session.data.get_preference(0) 
+    assert_equal 'hello', @session.data.get_preference(0)
   end
 
   private
   def example_set_cookie_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-    &lt;data_setCookie_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
+    &lt;data_setCookie_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot;&gt;1&lt;/data_setCookie_response&gt;
     XML
   end
@@ -53,7 +53,7 @@ class Facebooker::DataTest &lt; Test::Unit::TestCase
   def example_get_cookies_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-    &lt;data_getCookie_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
+    &lt;data_getCookie_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot;&gt;
       &lt;cookies&gt;
         &lt;uid&gt;508508326&lt;/uid&gt;
@@ -65,11 +65,11 @@ class Facebooker::DataTest &lt; Test::Unit::TestCase
     &lt;/data_getCookie_response&gt;
     XML
   end
-  
+
   def example_set_preference_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-    &lt;data_setUserPreference_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
+    &lt;data_setUserPreference_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot;/&gt;
     XML
   end
@@ -77,10 +77,10 @@ class Facebooker::DataTest &lt; Test::Unit::TestCase
   def example_get_preference_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-    &lt;data_getUserPreference_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
+    &lt;data_getUserPreference_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
     xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot;&gt;
       hello
     &lt;/data_getUserPreference_response&gt;
     XML
   end
-end
\ No newline at end of file
+end</diff>
      <filename>test/facebooker/data_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,9 +6,9 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
 
   def setup
     ENV['FACEBOOK_API_KEY'] = '1234567'
-    ENV['FACEBOOK_SECRET_KEY'] = '7654321'   
-    Facebooker.current_adapter = nil 
-    @session = Facebooker::Session.create('whatever', 'doesnotmatterintest')   
+    ENV['FACEBOOK_SECRET_KEY'] = '7654321'
+    Facebooker.current_adapter = nil
+    @session = Facebooker::Session.create('whatever', 'doesnotmatterintest')
     Facebooker.use_curl=false
   end
 
@@ -32,7 +32,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     flexmock(File).should_receive(:read).with(File.expand_path(&quot;~/.facebookerrc&quot;)).once.and_return('{:api =&gt; &quot;foo&quot;}')
     assert_equal('foo', Facebooker::Session.api_key)
   end
-  
+
   def test_if_environment_and_file_fail_to_match_then_an_exception_is_raised
     ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
     flexmock(File).should_receive(:read).with(File.expand_path(&quot;~/.facebookerrc&quot;)).once.and_return {raise Errno::ENOENT, &quot;No such file&quot;}
@@ -40,24 +40,24 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
       Facebooker::Session.api_key
     }
   end
-  
+
   def test_marshal_stores_api_key
     data = Marshal.dump(@session)
     loaded_session = Marshal.load(data)
     assert_equal 'whatever', loaded_session.instance_variable_get(&quot;@api_key&quot;)
   end
-  
+
   def test_marshal_stores_secret_key
     data = Marshal.dump(@session)
     loaded_session = Marshal.load(data)
-    assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get(&quot;@secret_key&quot;)    
+    assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get(&quot;@secret_key&quot;)
   end
-  
+
   def test_configuration_file_path_can_be_set_explicitly
     Facebooker::Session.configuration_file_path = '/tmp/foo'
     assert_equal('/tmp/foo', Facebooker::Session.configuration_file_path)
   end
-  
+
   def test_session_can_be_secured_with_existing_values
     session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     session.secure_with!(&quot;a session key&quot;, &quot;123456&quot;, Time.now.to_i + 60)
@@ -74,31 +74,31 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     assert_equal 'a session key', session.session_key
     assert_equal 321, session.user.to_i
   end
-  
+
   # The Facebook API for this is hideous.  Oh well.
   def test_can_ask_session_to_check_friendship_between_pairs_of_users
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     mock_http = establish_session
     mock_http.should_receive(:post_form).and_return(example_check_friendship_xml).once.ordered(:posts)
-    assert_equal({[222332, 222333] =&gt; true, [1240077, 1240079] =&gt; false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))    
+    assert_equal({[222332, 222333] =&gt; true, [1240077, 1240079] =&gt; false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))
   end
-  
+
   def test_facebook_can_claim_ignorance_as_to_friend_relationships
     mock_http = establish_session
-    mock_http.should_receive(:post_form).and_return(example_check_friendship_with_unknown_result).once.ordered(:posts)  
-    assert_equal({[1240077, 1240079] =&gt; nil}, @session.check_friendship([[1240077, 1240079]]))  
+    mock_http.should_receive(:post_form).and_return(example_check_friendship_with_unknown_result).once.ordered(:posts)
+    assert_equal({[1240077, 1240079] =&gt; nil}, @session.check_friendship([[1240077, 1240079]]))
   end
-  
+
   def test_can_query_with_fql
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
-    expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)    
+    expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
     response = @session.fql_query('Lets be frank. We are not testing the query here')
-    assert_kind_of(Facebooker::Photo, response.first)      
+    assert_kind_of(Facebooker::Photo, response.first)
   end
-  
+
   def test_anonymous_fql_results_get_put_in_a_positioned_array_on_the_model
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
-    expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)    
+    expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)
     response = @session.fql_query('Lets be frank. We are not testing the query here')
     assert_kind_of(Facebooker::Photo, response.first)
     response.each do |photo|
@@ -107,11 +107,11 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
   end
   def test_no_results_returns_empty_array
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
-    expect_http_posts_with_responses(no_results_fql)    
+    expect_http_posts_with_responses(no_results_fql)
     response = @session.fql_query('Lets be frank. We are not testing the query here')
     assert_equal [],response
   end
-  
+
   def test_can_fql_query_for_event_members
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     expect_http_posts_with_responses(example_fql_query_event_members_xml)
@@ -119,7 +119,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     assert_kind_of(Facebooker::Event::Attendance, response.first)
     assert_equal('attending', response.first.rsvp_status)
   end
-  
+
   def test_can_query_for_event_members
     expect_http_posts_with_responses(example_event_members_xml)
     event_attendances = @session.event_members(69)
@@ -128,19 +128,19 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     assert_equal([&quot;1240077&quot;, &quot;222332&quot;, &quot;222333&quot;, &quot;222335&quot;, &quot;222336&quot;], event_attendances.map{|ea| ea.uid}.sort)
     assert_equal 5, event_attendances.size
   end
-  
+
   def test_can_query_for_events
-    expect_http_posts_with_responses(example_events_get_xml)    
+    expect_http_posts_with_responses(example_events_get_xml)
     events = @session.events
     assert_equal 'Technology Tasting', events.first.name
   end
-  
+
   def test_can_query_for_groups
-    expect_http_posts_with_responses(example_groups_get_xml)    
+    expect_http_posts_with_responses(example_groups_get_xml)
     groups = @session.user.groups
     assert_equal 'Donald Knuth Is My Homeboy', groups.first.name
   end
-  
+
   def test_can_query_for_group_memberships
     expect_http_posts_with_responses(example_group_members_xml)
     example_group = Facebooker::Group.new({:gid =&gt; 123, :session =&gt; @session})
@@ -149,18 +149,18 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     assert_equal(123, group_memberships.last.gid)
     assert_equal(1240078, example_group.members.last.id)
   end
-  
+
   def test_can_fql_query_for_users_and_pictures
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     mock_http = establish_session
-    mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)  
+    mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
     response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
     assert_kind_of Array, response
     assert_kind_of Facebooker::User, response.first
     assert_equal &quot;Ari Steinberg&quot;, response.first.name
   end
-  
-  
+
+
   def test_can_send_notification_with_object
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     @session.expects(:post).with('facebook.notifications.send',{:to_ids=&gt;&quot;1&quot;,:notification=&gt;&quot;a&quot;,:type=&gt;&quot;user_to_user&quot;},true)
@@ -175,19 +175,19 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     @session.expects(:post).with('facebook.notifications.send',{:to_ids=&gt;&quot;1&quot;,:notification=&gt;&quot;a&quot;, :type=&gt;&quot;user_to_user&quot;},true)
     @session.send_notification([&quot;1&quot;],&quot;a&quot;)
   end
-  
+
   def test_can_send_announcement_notification
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     @session.expects(:post).with('facebook.notifications.send',{:to_ids=&gt;&quot;1&quot;,:notification=&gt;&quot;a&quot;, :type=&gt;&quot;app_to_user&quot;},false)
     @session.send_notification([&quot;1&quot;],&quot;a&quot;)
   end
-  
+
   def test_can_register_template_bundle
     expect_http_posts_with_responses(example_register_template_bundle_return_xml)
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     assert_equal 17876842716, @session.register_template_bundle(&quot;{*actor*} did something&quot;)
   end
-  
+
   def test_can_register_template_bundle_with_action_links
     expect_http_posts_with_responses(example_register_template_bundle_return_xml)
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@@ -198,7 +198,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     assert @session.publish_user_action(17876842716,{})
   end
-  
+
   def test_logs_api_calls
     call_name = 'sample.api.call'
     params = { :param1 =&gt; true, :param2 =&gt; 'value' }
@@ -207,7 +207,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     @session.post(call_name, params)
   end
-  
+
   def test_requests_inside_batch_are_added_to_batch
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     @session.send(:service).expects(:post).once
@@ -215,14 +215,14 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
       @session.send_notification([&quot;1&quot;],&quot;a&quot;)
       @session.send_notification([&quot;1&quot;],&quot;a&quot;)
     end
-    
+
   end
 
   def test_parses_batch_response
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     expect_http_posts_with_responses(example_batch_run_xml)
     @session.batch do
-      @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')      
+      @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
     end
     assert_kind_of(Facebooker::Event::Attendance, @fql_response.first)
     assert_equal('attending', @fql_response.first.rsvp_status)
@@ -231,9 +231,9 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     expect_http_posts_with_responses(example_batch_run_xml)
     Facebooker::FqlQuery.expects(:process).raises(NoMethodError.new)
-    
+
     @session.batch do
-      @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')      
+      @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
     end
     assert_raises(NoMethodError) {
       @fql_response.first
@@ -244,7 +244,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     Facebooker::BatchRun.current_batch=4
     assert_equal 4,Facebooker::BatchRun.current_batch
   end
-  
+
   def test_can_get_stanard_info
     expect_http_posts_with_responses(standard_info_xml)
     result = @session.users_standard([4])
@@ -267,21 +267,21 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     assert_equal &quot;4846711747&quot;, page.page_id
     assert_equal &quot;Kronos Quartet&quot;, page.name
     assert_equal &quot;http://www.kronosquartet.org&quot;, page.website
-    
+
     # TODO we really need a way to differentiate between hash/list and text attributes
     # assert_equal({}, page.company_overview)
-    
+
     # sakkaoui : as a fix to the parser, I replace empty text node by &quot;&quot; instead of {}
     # we have child.attributes['list'] == 'true' that let us know that we have a hash/list.
     assert_equal(&quot;&quot;, page.company_overview)
-    
+
     genre = page.genre
     assert_equal false, genre.dance
     assert_equal true, genre.party
   end
-    
+
   private
-  
+
   def example_groups_get_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -312,10 +312,10 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
           &lt;country&gt;United States&lt;/country&gt;
         &lt;/venue&gt;
       &lt;/group&gt;
-    &lt;/groups_get_response&gt;    
+    &lt;/groups_get_response&gt;
     XML
   end
-  
+
   def example_events_get_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -343,10 +343,10 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
           &lt;country&gt;United States&lt;/country&gt;
         &lt;/venue&gt;
       &lt;/event&gt;
-    &lt;/events_get_response&gt;    
+    &lt;/events_get_response&gt;
     XML
   end
-  
+
   def example_fql_query_event_members_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -378,10 +378,10 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
         &lt;uid2&gt;1240079&lt;/uid2&gt;
         &lt;are_friends&gt;0&lt;/are_friends&gt;
       &lt;/friend_info&gt;
-    &lt;/friends_areFriends_response&gt;    
+    &lt;/friends_areFriends_response&gt;
     XML
   end
-  
+
   def example_check_friendship_with_unknown_result
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -391,10 +391,10 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
         &lt;uid2&gt;1240079&lt;/uid2&gt;
         &lt;are_friends xsi:nil=&quot;true&quot;/&gt;
       &lt;/friend_info&gt;
-    &lt;/friends_areFriends_response&gt;    
+    &lt;/friends_areFriends_response&gt;
     XML
   end
-  
+
   def example_fql_for_multiple_users_and_pics
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -410,7 +410,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     &lt;/fql_query_response&gt;
     XML
   end
-  
+
   def example_fql_for_multiple_photos_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -433,7 +433,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     &lt;/fql_query_response&gt;
     XML
   end
-  
+
   def example_fql_for_multiple_photos_with_anon_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -462,16 +462,16 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     &lt;/fql_query_response&gt;
     XML
   end
-  
+
   def no_results_fql
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
     &lt;fql_query_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; list=&quot;true&quot;&gt;
     &lt;/fql_query_response&gt;
     XML
-    
+
   end
-  
+
   def example_group_members_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -490,21 +490,21 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
         &lt;uid&gt;1240078&lt;/uid&gt;
       &lt;/officers&gt;
       &lt;not_replied list=&quot;true&quot;/&gt;
-    &lt;/groups_getMembers_response&gt;    
+    &lt;/groups_getMembers_response&gt;
     XML
   end
-  
+
   def example_batch_run_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
     &lt;batch_run_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot; list=&quot;true&quot;&gt;
-      &lt;batch_run_response_elt&gt;    
+      &lt;batch_run_response_elt&gt;
       #{CGI.escapeHTML(example_fql_query_event_members_xml)}
       &lt;/batch_run_response_elt&gt;
     &lt;/batch_run_response&gt;
     XML
   end
-  
+
   def example_event_members_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -524,7 +524,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     &lt;/events_getMembers_response&gt;
     XML
   end
-  
+
   def example_register_template_bundle_return_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -551,7 +551,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     &lt;/pages_getInfo_response&gt;
     XML
   end
-  
+
   def publish_user_action_return_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -560,7 +560,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
     &lt;/feed_publishUserAction_response&gt;
     XML
   end
-  
+
   def standard_info_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -577,7 +577,7 @@ class Facebooker::SessionTest &lt; Test::Unit::TestCase
 end
 
 class PostMethodTest &lt; Test::Unit::TestCase
-  
+
   def setup
     Facebooker.use_curl = true
     Facebooker::Parser.stubs(:parse)
@@ -585,28 +585,28 @@ class PostMethodTest &lt; Test::Unit::TestCase
     @service = Facebooker::Service.new(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;)
     @service.stubs(&quot;url&quot;).returns(@uri)
   end
-  
+
   def teardown
     Facebooker.use_curl = false
   end
-  
+
   def test_use_curl_makes_post_with_curl
     @service.expects(:post_form_with_curl).with(@uri,{:method=&gt;&quot;a&quot;})
     @service.post(:method=&gt;&quot;a&quot;)
   end
-  
+
   def test_use_curl_makes_post_file_use_curl_with_multipart
     @service.expects(:post_form_with_curl).with(@uri,{:method=&gt;&quot;a&quot;},true)
-    @service.post_file(:method=&gt;&quot;a&quot;)    
+    @service.post_file(:method=&gt;&quot;a&quot;)
   end
 end
 
 class CanvasSessionTest &lt; Test::Unit::TestCase
   def setup
     ENV['FACEBOOK_API_KEY'] = '1234567'
-    ENV['FACEBOOK_SECRET_KEY'] = '7654321'   
+    ENV['FACEBOOK_SECRET_KEY'] = '7654321'
   end
-   
+
   def test_login_url_will_display_callback_url_in_canvas
     session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
     assert_equal(&quot;http://www.facebook.com/login.php?api_key=1234567&amp;v=1.0&amp;canvas=true&quot;, session.login_url)</diff>
      <filename>test/facebooker/session_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -485,7 +485,7 @@ class TestFacebooker &lt; Test::Unit::TestCase
   def example_notifications_send_xml
     &lt;&lt;-XML
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-&lt;notifications_send_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot;&gt;http://www.facebook.com/send_email.php?from=211031&amp;id=52&lt;/notifications_send_response&gt;
+&lt;notifications_send_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot;&gt;http://www.facebook.com/send_email.php?from=211031&amp;amp;id=52&lt;/notifications_send_response&gt;
     XML
   end
 </diff>
      <filename>test/facebooker_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,12 @@ require 'test/unit'
 require 'rubygems'
 
 begin
+  require 'nokogiri'
+rescue LoadError
+  # Should work without nokogiri
+end
+
+begin
   require 'multi_rails_init'
 rescue LoadError
   # multi rails not installed, test against newest supported version of Rails
@@ -39,10 +45,10 @@ class Test::Unit::TestCase
   def establish_session(session = @session)
     mock = flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml).once.ordered(:posts)
     mock.should_receive(:post_form).and_return(example_get_session_xml).once.ordered(:posts)
-    session.secure!    
+    session.secure!
     mock
   end
-  
+
   def example_auth_token_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
@@ -53,7 +59,7 @@ class Test::Unit::TestCase
         &lt;/auth_createToken_response&gt;    
     XML
   end
-  
+
   def example_get_session_xml
     &lt;&lt;-XML
     &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>00b3e473c8c63a397cb097a497292060fdd03864</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Patterson</name>
    <email>aaron.patterson@gmail.com</email>
  </author>
  <url>http://github.com/mmangino/facebooker/commit/ed216bb4742c758bcd9583a8c61930e9977774cb</url>
  <id>ed216bb4742c758bcd9583a8c61930e9977774cb</id>
  <committed-date>2009-05-04T16:04:24-07:00</committed-date>
  <authored-date>2009-05-04T16:04:24-07:00</authored-date>
  <message>nokogiri can optionally be used as the XML parser</message>
  <tree>a524ee86c2660399f957c5ac9e65b8e5bc3975df</tree>
  <committer>
    <name>Aaron Patterson</name>
    <email>aaron.patterson@gmail.com</email>
  </committer>
</commit>
