Class: Moxml::Adapter::CustomizedLibxml::Cdata

Inherits:
Node
  • Object
show all
Defined in:
lib/moxml/adapter/customized_libxml/cdata.rb

Overview

Wrapper for LibXML CDATA section nodes

Instance Attribute Summary

Attributes inherited from Node

#native

Instance Method Summary collapse

Methods inherited from Node

#==, #document, #document_present?, #hash, #initialize, #replace_native!

Constructor Details

This class inherits a constructor from Moxml::Adapter::CustomizedLibxml::Node

Instance Method Details

#to_xmlObject

libxml stores CDATA payload verbatim. Only the ]]> end-marker needs splitting before re-wrapping.



10
11
12
13
# File 'lib/moxml/adapter/customized_libxml/cdata.rb', line 10

def to_xml
  escaped_content = @native.content.gsub("]]>", "]]]]><![CDATA[>")
  "<![CDATA[#{escaped_content}]]>"
end