Class: Canon::Formatters::XmlFormatter
- Inherits:
-
Object
- Object
- Canon::Formatters::XmlFormatter
- Defined in:
- lib/canon/formatters/xml_formatter.rb
Class Method Summary collapse
Class Method Details
.format(xml, pretty: true, indent: 2) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/canon/formatters/xml_formatter.rb', line 8 def self.format(xml, pretty: true, indent: 2) if pretty Canon::PrettyPrinter::Xml.new(indent: indent).format(xml) else Canon::Xml::C14n.canonicalize(xml, with_comments: false) end end |
.parse(xml) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/canon/formatters/xml_formatter.rb', line 16 def self.parse(xml) Canon::Validators::XmlValidator.validate!(xml) if XmlBackend.nokogiri? Nokogiri::XML(xml) else XmlParsing.parse(xml) end end |