Module: Oga

Defined in:
lib/oga/oga.rb,
lib/oga/version.rb,
lib/oga/xml/text.rb,
lib/oga/xml/node.rb,
lib/oga/xml/lexer.rb,
lib/oga/xml/cdata.rb,
lib/oga/xml/element.rb,
lib/oga/xml/doctype.rb,
lib/oga/html/parser.rb,
lib/oga/xml/comment.rb,
lib/oga/xml/querying.rb,
lib/oga/xml/document.rb,
lib/oga/xml/node_set.rb,
lib/oga/xml/entities.rb,
lib/oga/xml/attribute.rb,
lib/oga/xml/namespace.rb,
lib/oga/xml/traversal.rb,
lib/oga/xml/sax_parser.rb,
lib/oga/xpath/evaluator.rb,
lib/oga/html/sax_parser.rb,
lib/oga/xml/pull_parser.rb,
lib/oga/xml/character_node.rb,
lib/oga/xml/xml_declaration.rb,
lib/oga/xml/html_void_elements.rb,
lib/oga/xml/processing_instruction.rb

Defined Under Namespace

Modules: HTML, XML, XPath

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.parse_html(html) ⇒ Oga::XML::Document

Parses the given HTML document.

Examples:

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

24
25
26
# File 'lib/oga/oga.rb', line 24

def self.parse_html(html)
  return HTML::Parser.new(html).parse
end

.parse_xml(xml) ⇒ Oga::XML::Document

Parses the given XML document.

Examples:

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

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

def self.parse_xml(xml)
  return XML::Parser.new(xml).parse
end

.sax_parse_html(handler, html) ⇒ Object

Parses the given HTML document using the SAX parser.

Examples:

handler = SomeSaxHandler.new

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

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

def self.sax_parse_html(handler, html)
  HTML::SaxParser.new(handler, html).parse
end

.sax_parse_xml(handler, xml) ⇒ Object

Parses the given XML document using the SAX parser.

Examples:

handler = SomeSaxHandler.new

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

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

def self.sax_parse_xml(handler, xml)
  XML::SaxParser.new(handler, xml).parse
end