Module: Ronin::Web::XML

Defined in:
lib/ronin/web/xml.rb

Overview

XML helper methods.

Since:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.build { ... } ⇒ Nokogiri::XML::Builder

Creates a new Nokogiri::XML::Builder.

Examples:

HTML.build do
  html {
    body {
      div(style: 'display:none;') {
        object(classid: 'blabla')
      }
    }
  }
end

Yields:

  • [] The block that will be used to construct the XML document.

Returns:

  • (Nokogiri::XML::Builder)

    The new XML builder object.

See Also:

Since:

  • 1.0.0



81
82
83
# File 'lib/ronin/web/xml.rb', line 81

def self.build(&block)
  Nokogiri::XML::Builder.new(&block)
end

.parse(xml) {|doc| ... } ⇒ Nokogiri::XML::Document

Parses the body of a document into a HTML document object.

Parameters:

  • xml (String, IO)

    The XML to parse.

Yields:

  • (doc)

    If a block is given, it will be passed the newly created document object.

Yield Parameters:

  • doc (Nokogiri::XML::Document)

    The new XML document object.

Returns:

  • (Nokogiri::XML::Document)

    The new HTML document object.

See Also:

Since:

  • 1.0.0



51
52
53
54
55
# File 'lib/ronin/web/xml.rb', line 51

def self.parse(xml)
  doc = Nokogiri::XML.parse(xml)
  yield doc if block_given?
  return doc
end