Class: Moxml::Adapter::CustomizedLibxml::Comment

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

Overview

Wrapper for LibXML comment nodes

Instance Attribute Summary

Attributes inherited from Node

#native

Instance Method Summary collapse

Methods inherited from Node

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

Constructor Details

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

Instance Method Details

#to_xmlObject

Serialize as XML comment LibXML auto-escapes content, we need to un-escape it



12
13
14
15
16
17
18
19
20
# File 'lib/moxml/adapter/customized_libxml/comment.rb', line 12

def to_xml
  content = @native.content
    .gsub(""", '"')
    .gsub("'", "'")
    .gsub("&lt;", "<")
    .gsub("&gt;", ">")
    .gsub("&amp;", "&")
  "<!--#{content}-->"
end