Module: Oga

Defined in:
lib/oga/css/lexer.rb,
lib/oga/lru.rb,
lib/oga/oga.rb,
lib/oga/version.rb,
lib/oga/xml/node.rb,
lib/oga/xml/text.rb,
lib/oga/blacklist.rb,
lib/oga/ruby/node.rb,
lib/oga/whitelist.rb,
lib/oga/xml/cdata.rb,
lib/oga/xml/lexer.rb,
lib/oga/css/parser.rb,
lib/oga/xml/parser.rb,
lib/oga/xml/to_xml.rb,
lib/oga/html/parser.rb,
lib/oga/xml/comment.rb,
lib/oga/xml/doctype.rb,
lib/oga/xml/element.rb,
lib/oga/xpath/lexer.rb,
lib/oga/xml/document.rb,
lib/oga/xml/entities.rb,
lib/oga/xml/node_set.rb,
lib/oga/xml/querying.rb,
lib/oga/xpath/parser.rb,
lib/oga/html/entities.rb,
lib/oga/xml/attribute.rb,
lib/oga/xml/generator.rb,
lib/oga/xml/namespace.rb,
lib/oga/xml/traversal.rb,
lib/oga/xpath/context.rb,
lib/oga/entity_decoder.rb,
lib/oga/ruby/generator.rb,
lib/oga/xml/sax_parser.rb,
lib/oga/xpath/compiler.rb,
lib/oga/html/sax_parser.rb,
lib/oga/xml/pull_parser.rb,
lib/oga/xpath/conversion.rb,
lib/oga/xml/expanded_name.rb,
lib/oga/xml/character_node.rb,
lib/oga/xml/xml_declaration.rb,
lib/oga/xml/default_namespace.rb,
lib/oga/xml/html_void_elements.rb,
lib/oga/xml/processing_instruction.rb

Overview

line 3 “lib/oga/xpath/lexer.rl”

Defined Under Namespace

Modules: CSS, EntityDecoder, HTML, Ruby, XML, XPath Classes: Blacklist, LRU, Whitelist

Constant Summary collapse

VERSION =
'3.1'

Class Method Summary collapse

Class Method Details

.parse_html(html, options = {}) ⇒ Oga::XML::Document

Parses the given HTML document.

Examples:

document = Oga.parse_html('<html>...</html>')

Returns:

See Also:

  • [Oga[Oga::XML[Oga::XML::Lexer[Oga::XML::Lexer#initialize]


22
23
24
# File 'lib/oga/oga.rb', line 22

def self.parse_html(html, options = {})
  HTML::Parser.new(html, options).parse
end

.parse_xml(xml, options = {}) ⇒ Oga::XML::Document

Parses the given XML document.

Examples:

document = Oga.parse_xml('<root>Hello</root>')

Returns:

See Also:

  • [Oga[Oga::XML[Oga::XML::Lexer[Oga::XML::Lexer#initialize]


10
11
12
# File 'lib/oga/oga.rb', line 10

def self.parse_xml(xml, options = {})
  XML::Parser.new(xml, options).parse
end

.sax_parse_html(handler, html, options = {}) ⇒ Object

Parses the given HTML document using the SAX parser.

Examples:

handler = SomeSaxHandler.new

Oga.sax_parse_html(handler, '<script>foo()</script>')

See Also:

  • [Oga[Oga::XML[Oga::XML::SaxParser[Oga::XML::SaxParser#initialize]


46
47
48
# File 'lib/oga/oga.rb', line 46

def self.sax_parse_html(handler, html, options = {})
  HTML::SaxParser.new(handler, html, options).parse
end

.sax_parse_xml(handler, xml, options = {}) ⇒ Object

Parses the given XML document using the SAX parser.

Examples:

handler = SomeSaxHandler.new

Oga.sax_parse_html(handler, '<root>Hello</root>')

See Also:

  • [Oga[Oga::XML[Oga::XML::SaxParser[Oga::XML::SaxParser#initialize]


34
35
36
# File 'lib/oga/oga.rb', line 34

def self.sax_parse_xml(handler, xml, options = {})
  XML::SaxParser.new(handler, xml, options).parse
end