<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Module: FeedParser</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" /> <script type="text/javascript"> // <![CDATA[ function popupCode( url ) { window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") } function toggleCode( id ) { if ( document.getElementById ) elem = document.getElementById( id ); else if ( document.all ) elem = eval( "document.all." + id ); else return false; elemStyle = elem.style; if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { elemStyle.display = "none" } return true; } // Make codeblocks hidden by default document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) // ]]> </script> </head> <body> <div id="classHeader"> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Module</strong></td> <td class="class-name-in-header">FeedParser</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../files/lib/feedparser/html2text-parser_rb.html"> lib/feedparser/html2text-parser.rb </a> <br /> <a href="../files/lib/feedparser/text-output_rb.html"> lib/feedparser/text-output.rb </a> <br /> <a href="../files/lib/feedparser/sgml-parser_rb.html"> lib/feedparser/sgml-parser.rb </a> <br /> <a href="../files/lib/feedparser/html-output_rb.html"> lib/feedparser/html-output.rb </a> <br /> <a href="../files/lib/feedparser/feedparser_rb.html"> lib/feedparser/feedparser.rb </a> <br /> </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="diagram"> <map id="map" name="map"> <area shape="rect" coords="1435,5,1600,53" href="RuntimeError.html" alt="RuntimeError" /> <area shape="rect" coords="1364,161,1671,209" href="FeedParser/UnknownFeedTypeException.html" alt="UnknownFeedTypeException" /> <area shape="rect" coords="887,136,1340,235" href="FeedParser/FeedItem.html" alt="FeedItem\n[lib/feedparser/feedparser.rb\nlib/feedparser/html-output.rb\nlib/feedparser/text-output.rb]" /> <area shape="rect" coords="987,283,1104,331" href="FeedParser/AtomItem.html" alt="AtomItem" /> <area shape="rect" coords="1128,283,1235,331" href="FeedParser/RSSItem.html" alt="RSSItem" /> <area shape="rect" coords="79,161,220,209" href="FeedParser/SGMLParser.html" alt="SGMLParser" /> <area shape="rect" coords="48,283,251,331" href="FeedParser/HTML2TextParser.html" alt="HTML2TextParser" /> <area shape="rect" coords="409,136,863,235" href="FeedParser/Feed.html" alt="Feed\n[lib/feedparser/feedparser.rb\nlib/feedparser/html-output.rb\nlib/feedparser/text-output.rb]" /> <area shape="rect" coords="399,100,1681,341" href="FeedParser.html" alt="lib/feedparser/feedparser.rb" /> <area shape="rect" coords="60,125,372,220" href="FeedParser.html" alt="lib/feedparser/sgml-parser.rb" /> <area shape="rect" coords="27,247,388,341" href="FeedParser.html" alt="lib/feedparser/html2text-parser.rb" /> <area shape="rect" coords="16,64,1692,352" href="FeedParser.html" alt="FeedParser" /> </map> <img src="../dot/m_8_0.png" usemap="#map" border="0" alt="dot/m_8_0.png"> </div> <div id="description"> <p> A parser for SGML, using the derived class as static DTD. from <a href="http://raa.ruby-lang.org/project/html-parser">raa.ruby-lang.org/project/html-parser</a> </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000015">getcontent</a> </div> </div> </div> <!-- if includes --> <div id="section"> <div id="class-list"> <h3 class="section-bar">Classes and Modules</h3> Class <a href="FeedParser/AtomItem.html" class="link">FeedParser::AtomItem</a><br /> Class <a href="FeedParser/Feed.html" class="link">FeedParser::Feed</a><br /> Class <a href="FeedParser/FeedItem.html" class="link">FeedParser::FeedItem</a><br /> Class <a href="FeedParser/HTML2TextParser.html" class="link">FeedParser::HTML2TextParser</a><br /> Class <a href="FeedParser/RSSItem.html" class="link">FeedParser::RSSItem</a><br /> Class <a href="FeedParser/SGMLParser.html" class="link">FeedParser::SGMLParser</a><br /> Class <a href="FeedParser/UnknownFeedTypeException.html" class="link">FeedParser::UnknownFeedTypeException</a><br /> </div> <div id="constants-list"> <h3 class="section-bar">Constants</h3> <div class="name-list"> <table summary="Constants"> <tr class="top-aligned-row context-row"> <td class="context-item-name">VERSION</td> <td>=</td> <td class="context-item-value">"0.6"</td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Class methods</h3> <div id="method-M000015" class="method-detail"> <a name="M000015"></a> <div class="method-heading"> <a href="#M000015" class="method-signature"> <span class="method-name">getcontent</span><span class="method-args">(e, feed = nil)</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000015-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000015-source"> <pre> <span class="ruby-comment cmt"># File lib/feedparser/feedparser.rb, line 276</span> 276: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FeedParser</span><span class="ruby-operator">::</span><span class="ruby-identifier">getcontent</span>(<span class="ruby-identifier">e</span>, <span class="ruby-identifier">feed</span> = <span class="ruby-keyword kw">nil</span>) 277: <span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">feed</span> <span class="ruby-value">? </span><span class="ruby-identifier">feed</span>.<span class="ruby-identifier">encoding</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'utf-8'</span> 278: <span class="ruby-identifier">children</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">reject</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> 279: <span class="ruby-identifier">i</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Text</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">chomp</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span> 280: <span class="ruby-keyword kw">end</span> 281: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">children</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span> 282: <span class="ruby-identifier">s</span> = <span class="ruby-value str">''</span> 283: <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> 284: <span class="ruby-identifier">s</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Comment</span> 285: <span class="ruby-keyword kw">end</span> 286: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">toUTF8</span>(<span class="ruby-identifier">encoding</span>).<span class="ruby-identifier">rmWhiteSpace!</span>.<span class="ruby-identifier">text2html</span>(<span class="ruby-identifier">feed</span>) 287: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">children</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> 288: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>] 289: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Text</span> 290: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">toUTF8</span>(<span class="ruby-identifier">encoding</span>).<span class="ruby-identifier">rmWhiteSpace!</span>.<span class="ruby-identifier">text2html</span>(<span class="ruby-identifier">feed</span>) 291: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">CData</span> 292: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">toUTF8</span>(<span class="ruby-identifier">encoding</span>).<span class="ruby-identifier">rmWhiteSpace!</span>.<span class="ruby-identifier">text2html</span>(<span class="ruby-identifier">feed</span>) 293: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span> 294: <span class="ruby-comment cmt"># only one element. recurse.</span> 295: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">getcontent</span>(<span class="ruby-identifier">c</span>, <span class="ruby-identifier">feed</span>) 296: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">text</span> 297: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">toUTF8</span>(<span class="ruby-identifier">encoding</span>).<span class="ruby-identifier">text2html</span>(<span class="ruby-identifier">feed</span>) 298: <span class="ruby-keyword kw">end</span> 299: <span class="ruby-keyword kw">end</span> 300: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> </div> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>