Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does one remove <![CDATA[ ]]> tags from around text in XML using Hpricot?

i just want the text out of there with out those tags. Does Hrpicot.XML have any methods for this?

like image 375
loosecannon Avatar asked Jan 21 '23 13:01

loosecannon


2 Answers

use element.inner_text instead of #inner_html and it removes them for you

like image 72
loosecannon Avatar answered Mar 17 '23 14:03

loosecannon


doc.search("*") do |element|
    element.swap element.content if element.kind_of? Hpricot::CData
end
like image 33
Daniel O'Hara Avatar answered Mar 17 '23 13:03

Daniel O'Hara