title: Search keyword from HTTP response in #<Nokogiri::XML::Comment data
body: <p>I am using ruby to send a http request, and receive response. Now I need to search for a keyword in the response. I use Nokogiri::HTML(response.body) and following is the part of the http response that I want to look into for the keyword:</p>
  
  <pre><code>#&lt;Nokogiri::XML::Comment:0x0c24940 "\n\t&lt;div style=\"float:left;margin-left:20px;width:200px;\"&gt;\n\t&lt;p&gt;&lt;strong&gt;Check this&lt;/strong&gt;&lt;/p&gt;\n\t&lt;ul&gt;\n\t\t&lt;li&gt;&lt;a href='http://www.example.com' target='_blank'&gt;example.com&lt;/a&gt;&lt;/li&gt;\n\t\t&lt;li&gt;&lt;a href='http://www.example.com/hello' target='_blank'&gt;example only&lt;/a&gt;&lt;/li&gt;\n\t\t&lt;li&gt;&lt;a href=\"javascript:void(0)\" onclick=\"window.open( '/path/to/example.xml', '', 'scrollbars=yes,menubar=no,height=800,width=1000,resizable=yes,toolbar=no,location=no,status=no' );\"&gt;Example with Coffee&lt;/a&gt;&lt;/li&gt;\n\t&lt;/ul&gt;\n\n\t&lt;/div&gt;\n"&gt;
  </code></pre>
  
  <p>Just to make clear, the http response has several other components in addition to above, like:</p>
  
  <blockquote>
    <p><code>#&lt;Nokogiri::XML::Text, ::Element</code></p>
  </blockquote>
  
  <p>and more <code>::Comments</code> etc, and each have different numeric IDs like 
  <code>#&lt;Nokogiri::XML::Comment:0x0c24940</code>, <code>#&lt;Nokogiri::XML::Text:0x1e21321</code>, etc.</p>
  
  <p>How can I retrieve the string '<code>Example with Coffee</code>' out of the http response using nokogiri?</p>
  
  <p><strong>Update</strong>
  Adding part of HTML response as well:</p>
  
  <pre><code>#&lt;Nokogiri::HTML::Document:0x53a5ef4 name="document" children=[#&lt;Nokogiri::XML::DTD:0x53a0cb4 name="html"&gt;, #&lt;Nokogiri::XML::Element:0x53112c8 name="html" children=[#&lt;Nokogiri::XML::Text:0x51e3f74 "\n\t"&gt;, #&lt;Nokogiri::XML::Element:0x52d2168 name="head" children=[#&lt;Nokogiri::XML::Text:0x51c3738 "\n\t\t\n\t\t"&gt;, #&lt;Nokogiri::XML::Comment:0x523dfa4 " These meta tags will prevent the browser from caching the page --!&gt;\n\t\t&lt;meta http-equiv='cache-control' content='no-cache'&gt;\n\t\t&lt;meta http-equiv='expires' content='0'&gt;\n\t\t&lt;meta http-equiv='pragma' content='no-cache'&gt;\n\n\t\t&lt;!-- Stylesheets "&gt;, #&lt;Nokogiri::XML::Text:0x51b9d3c " \n\t\t"&gt;, #&lt;Nokogiri::XML::Element:0x52ae0b2 name="link" attributes=[#&lt;Nokogiri::XML::Attr:0x52accc0 name="type" value="text/css"&gt;, #&lt;Nokogiri::XML::Attr:0x52s2cfc name="rel" value="stylesheet"&gt;, #&lt;Nokogiri::XML::Attr:0x52a1eb4 name="href" value="/styles/main.css"&gt;]&gt;, #&lt;Nokogiri::XML::Text:0x5251b70 "\n\t\t"&gt;, #&lt;Nokogiri::XML::Element:0x5d59ed0 name="style" attributes=[#&lt;Nokogiri::XML::Attr:0x5c5ab20 name="type" value="text/css"&gt;] children=[#&lt;Nokogiri::XML::CDATA:0x51eca30 "\n\t\t\tul li { margin-left: -20px; }\n\t\t\t#checkPage1 { \n\t\t\t\tdisplay: inline-block;\n\t\t\t\t*display: inline;\n\t\t\t\tborder: 1px solid #618CB3;\n\t\t\t\tbackground-color: #FEFEFE;\n\t\t\t\tpadding: 3px;\n\t\t\t}\n\t\t\t
  </code></pre>
  
  <p>Here's the original HTML request &amp; response:</p>
  
  <pre><code>&gt;&gt; uri = URI.parse("http://&lt;1.2.3.4&gt;/about/index.php")
  =&gt; #&lt;URI::HTTP:0x00000008ee6760 URL:http://1.2.3.4/about/index.php&gt;
  &gt;&gt; http = Net::HTTP.new(uri.host, uri.port)
  =&gt; #&lt;Net::HTTP 1.2.3.4 open=false&gt;
  &gt;&gt; request = Net::HTTP::Get.new(uri.request_uri)
  =&gt; #&lt;Net::HTTP::Get GET&gt;
  &gt;&gt; request['Cookie'] = 'Fruits=12345'
  =&gt; "Fruits=12345"
  &gt;&gt; response = http.request(request)
  =&gt; #&lt;Net::HTTPOK 200 OK readbody=true&gt;
  &gt;&gt; response.body
  =&gt; "&lt;html&gt;\n\t&lt;head&gt;\n\t\t\n\t\t&lt;!-- These meta tags will prevent the browser from caching the page --!&gt;\n\t\t&lt;meta http-equiv='cache-control' content='no-cache'&gt;\n\t\t&lt;meta http-equiv='expires' content='0'&gt;\n\t\t&lt;meta http-equiv='pragma' content='no-cache'&gt;\n\n\t\t&lt;!-- Stylesheets --&gt; \n\t\t&lt;link type=\"text/css\" rel=\"stylesheet\" href=\"/styles/main.css\"&gt;\n\t\t&lt;style type=\"text/css\"&gt;\n\t\t\tul li { margin-left: -20px; }\n\t\t\t#licDiv { \n\t\t\t\tdisplay: inline-block;\n\t\t\t\t*display: inline;\n\t\t\t\tborder: 1px solid #6186B3;\n\t\t\t\tbackground-color: #FEFEFE;\n\t\t\t\tpadding: 3px;\n\t\t\t}\n\t\t\t#licDiv p {\n\t\t\t\tmargin: 2px 0;\n\t\t\t}\n\t\t\t.nobullets {\n\t\t\t\tpadding-left: 10;\n\t\t\t}\n\t\t\t.nobullets li {\n\t\t\t\tlist-style: none;\n\t\t\t}\n\t\t&lt;/style&gt;\n\t\t\n\t\t&lt;!-- Scripts --&gt;\n\t\t&lt;script type=\"text/javascript\" src=\"/GlobalData.js\"&gt;&lt;/script&gt;\n\t\t&lt;script type=\"text/javascript\"&gt;\n\t\t\tfunction fn1() {\n\n\t\t\t\t// Disable Caching\n\t\t\t\t//$.ajaxSetup({cache: false}});\n\n\t\t\t\tif( window.XMLHttpRequest ) {\n\t\t\t\t\t// Code for IE7+, Firefox, Chrome, Opera, Safari\n\t\t\t\t\txmlhttp = new XMLHttpRequest();\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Code for IE6\n\t\t\t\t\txmlhttp = new ActiveXObject( \"Microsoft.XMLHTTP\" );\n\t\t\t\t}\n\t\t\t\txmlhttp.onreadystatechange = function() {\n\t\t\t\t\tif( xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200 ) {\n\t\t\t\t\t\tcheck2 = xmlhttp.responseText;\n\t\t\t\t\t\tif( 0 == check2 ) {\n\t\t\t\t\t\t\talert( \"msg1.\" );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\talert( \"Issue1.\" );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\txmlhttp.open( \"GET\", \"page1.php\", true );\n\t\t\t\txmlhttp.send();\n\t\t\t}\n\t\t&lt;/script&gt;\n\n\t&lt;/head&gt;\n\t\n\t&lt;body style=\"\"&gt;\n\n\t\t&lt;!-- Page Title --&gt;\n\t\t&lt;div class=\"pageTitle\"&gt;\n\t\t\t&lt;img src=\"/images/page_about.png\"/&gt;\n\t\t\tAbout\t\t&lt;/div&gt;\n\n\t\t&lt;!-- The Main Area --&gt;\n\t\t&lt;div class=\"container\" style=\"height:700px;\"&gt;\n\n\t&lt;p&gt;&lt;strong&gt;This is a big juicy \"apple\" (Fruit)&lt;/strong&gt;&lt;/p&gt;\n\t&lt;ul&gt;\n&lt;div style=\"float:left;margin-left:20px;width:200px;\"&gt;\n\t&lt;p&gt;&lt;strong&gt;Helpful Links&lt;/strong&gt;&lt;/p&gt;\n\t&lt;ul&gt;\n\t\t&lt;li&gt;&lt;a href='http://www.fruits.com' target='_blank'&gt;Fruits.com&lt;/a&gt;&lt;/li&gt;\n\t\t&lt;li&gt;&lt;a href='http://www.fruits.com/apple' target='_blank'&gt;Apple Fruit&lt;/a&gt;&lt;/li&gt;\n\t\t&lt;li&gt;&lt;a href=\"javascript:void(0)\" onclick=\"window.open( '/manual/apple.xml', '', 'scrollbars=yes,menubar=no,height=800,width=1000,resizable=yes,toolbar=no,location=no,status=no' );\"&gt;Example with Coffee&lt;/a&gt;&lt;/li&gt;\n\t&lt;/ul&gt;\n\n\t&lt;/div&gt;\n--&gt;\n\t&lt;p style=\"clear:both;\"&gt;
  </code></pre>
  
  <p><strong>HTML Page Source</strong></p>
  
  <blockquote>
    <p><a href="http://pastie.org/8020148#10" rel="nofollow">http://pastie.org/8020148#10</a></p>
  </blockquote>