Class: Common::XmlTools

Inherits:
Object
  • Object
show all
Defined in:
lib/common/xml_tools.rb

Overview

Some tools facilitating xml processing.

Class Method Summary collapse

Class Method Details

.strip_cdata(xml_with_cdata) ⇒ Object

Get rid of surrounding cdata sections.

Parameter

xml_with_cdata

Some xml string with a cdata section.



19
20
21
22
23
# File 'lib/common/xml_tools.rb', line 19

def self.strip_cdata(xml_with_cdata)
  xml_with_cdata.gsub('<![CDATA[', '')
  xml_with_cdata.gsub(']]>', '')
  return xml_with_cdata
end

.strip_cdata!(xml_with_cdata) ⇒ Object

Get rid of surrounding cdata sections. Attention: This method will modify the given string itself.

Parameter

xml_with_cdata

Some xml string with a cdata section.



10
11
12
13
14
# File 'lib/common/xml_tools.rb', line 10

def self.strip_cdata!(xml_with_cdata)
  xml_with_cdata.gsub!('<![CDATA[', '')
  xml_with_cdata.gsub!(']]>', '')
  return xml_with_cdata
end