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/whitelist.rb,
lib/oga/xml/cdata.rb,
lib/oga/xml/lexer.rb,
lib/oga/css/parser.rb,
lib/oga/xml/parser.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/namespace.rb,
lib/oga/xml/traversal.rb,
lib/oga/entity_decoder.rb,
lib/oga/xml/sax_parser.rb,
lib/oga/html/sax_parser.rb,
lib/oga/xml/pull_parser.rb,
lib/oga/xpath/evaluator.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, XML, XPath Classes: Blacklist, LRU, Whitelist

Constant Summary collapse

VERSION =
'1.0.3'

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]


26
27
28
# File 'lib/oga/oga.rb', line 26

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]


12
13
14
# File 'lib/oga/oga.rb', line 12

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]


54
55
56
# File 'lib/oga/oga.rb', line 54

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]


40
41
42
# File 'lib/oga/oga.rb', line 40

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