Module: Ronin::Support::Web::XML::Mixin

Included in:
Mixin
Defined in:
lib/ronin/support/web/xml/mixin.rb

Overview

Provides helper methods for working with XML.

Instance Method Summary collapse

Instance Method Details

#xml_build { ... } ⇒ Nokogiri::XML::Builder

Creates a new Nokogiri::XML::Builder.

Examples:

xml_build do
  root {
    foo(id: 'bar')
  }
end

Yields:

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

Returns:

  • (Nokogiri::XML::Builder)

    The new XML builder object.

See Also:



104
105
106
# File 'lib/ronin/support/web/xml/mixin.rb', line 104

def xml_build(&block)
  XML.build(&block)
end

#xml_open(path) {|doc| ... } ⇒ Nokogiri::XML::Document Also known as: open_xml

Opens an XML file.

Examples:

doc = XML.open('index.xml')
# => #<Nokogiri::XML::Document:...>

Parameters:

  • path (String)

    The path to the XML file.

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 parsed XML file.

See Also:



79
80
81
# File 'lib/ronin/support/web/xml/mixin.rb', line 79

def xml_open(path,&block)
  XML.open(path,&block)
end

#xml_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:



52
53
54
# File 'lib/ronin/support/web/xml/mixin.rb', line 52

def xml_parse(xml,&block)
  XML.parse(xml,&block)
end