rssモジュールを利用して
rubyでrss2.0を出力するプログラムを作っているのですが、
1か所、うまくいきません。
うまくいかない所は
descriptionの項目に「<CDATA[なんちゃら~」と書くと
なんちゃらの部分はhtml_escapeされて
rss
1 <description> 2 <![CDATA[<img src=https://amd.c.yimg.jp/im_siggCB0P2WlcKh4RxvwE3l0I3w---x150-y84-q90/amd/20180105-00000045-natalieo-000-0-thumb.jpg ><BR>…BSプレミアム)にガンバレルーヤ、はなしょー、阿佐ヶ谷姉妹、平野ノラ、相席スタート・ケイら多数の女性芸人が出演する。この番組は久本雅美が昨年活躍した女性…<BR>1月5日(金) 14時38分 エンタメ総合(お笑いナタリー)]]> 3 </description>
となってしまいます。
出力としては、↓というように、出力したいのですが、
うまくいきません。
rss
1 2 <description> 3<![CDATA[<img src=https://amd.c.yimg.jp/im_siggCB0P2WlcKh4RxvwE3l0I3w---x150-y84-q90/amd/20180105-00000045-natalieo-000-0-thumb.jpg ><BR>…BSプレミアム)にガンバレルーヤ、はなしょー、阿佐ヶ谷姉妹、平野ノラ、相席スタート・ケイら多数の女性芸人が出演する。この番組は久本雅美が昨年活躍した女性…<BR>1月5日(金) 14時38分 エンタメ総合(お笑いナタリー)]]> 4 </description>
モンキーパッチを入れると可能らしいという事で
http://motivation.drivendevelopment.jp/2009-12-02-1.html
をそのまま使ったのですが、
変わりませんでした。
rssモジュールでは無い方法もあるようですが、
rssモジュールでできるようにしたいです。
(rssモジュールの投稿日ソートを使っているので)
よろしくお願いします。
作成部分のコードは、こんな感じ
モンキーパッチの部分は
http://motivation.drivendevelopment.jp/2009-12-02-1.html
をそのまま入れています。
ruby
1 2 3 4 rss = RSS::Maker.make("2.0") do |xml| 5 xss = xml.xml_stylesheets.new_xml_stylesheet 6# xss.href = "http://example.com/index.xsl" 7 8 xml.items.do_sort = true 9 10 xss.href = http://hogehoge/index.xml" 11 xml.channel.title = "Sample" 12 xml.channel.link = 'http://hogehoge" 13 xml.channel.about = "http://hogehoge/news.xml" 14 xml.channel.description = "ほげほげ" 15 16 xml.items.new_item do |item| 17 item.title = "アイテムタイトル" 18 item.link = "http://hogehoge" 19 20 description ="" 21 description << "<img src=" + img_url + " >" 22 description << "<BR>" 23 description << "ほげほげ" 24 25#いろいろやってみた。けど・・・ 26 27# item.description do 28# item.cdata! description 29# end 30# item.description = "<![CDATA[" + description + "]]>" 31 32 item.content_encoded = description 33 34# xml.description do 35# xml.cdata do 36# xml << description 37# end 38# end 39 end 40 end 41
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/07 06:51
2018/01/07 06:56