Module: Nokogiri

Defined in:
lib/nokogiri.rb,
lib/nokogiri/xml.rb,
lib/nokogiri/html.rb,
lib/nokogiri/xslt.rb,
lib/nokogiri/hpricot.rb,
lib/nokogiri/version.rb,
lib/nokogiri/xml/sax.rb,
lib/nokogiri/css/node.rb,
lib/nokogiri/xml/node.rb,
lib/nokogiri/xml/text.rb,
lib/nokogiri/xml/xpath.rb,
lib/nokogiri/css/parser.rb,
lib/nokogiri/xml/reader.rb,
lib/nokogiri/xml/builder.rb,
lib/nokogiri/html/builder.rb,
lib/nokogiri/xml/document.rb,
lib/nokogiri/xml/node_set.rb,
lib/nokogiri/css/tokenizer.rb,
lib/nokogiri/html/document.rb,
lib/nokogiri/xml/sax/parser.rb,
lib/nokogiri/html/sax/parser.rb,
lib/nokogiri/xslt/stylesheet.rb,
lib/nokogiri/xml/sax/document.rb,
lib/nokogiri/css/xpath_visitor.rb,
lib/nokogiri/xml/after_handler.rb,
lib/nokogiri/xml/before_handler.rb,
lib/nokogiri/decorators/hpricot/node.rb,
lib/nokogiri/decorators/hpricot/node_set.rb,
lib/nokogiri/decorators/hpricot/xpath_visitor.rb,
ext/nokogiri/xml_cdata.c,
ext/nokogiri/xml_xpath.c,
ext/nokogiri/xml_reader.c,
ext/nokogiri/xml_xpath_context.c

Defined Under Namespace

Modules: CSS, Decorators, HTML, Hpricot, XML, XSLT

Constant Summary collapse

VERSION =
'0.0.0'

Class Method Summary collapse

Class Method Details

.Hpricot(*args, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/nokogiri/hpricot.rb', line 36

def Hpricot(*args, &block)
  if block_given?
    builder = Nokogiri::HTML::Builder.new(&block)
    Nokogiri::Hpricot.add_decorators(builder.doc)
  else
    doc = Nokogiri::HTML.parse(*args)
    Nokogiri::Hpricot.add_decorators(doc)
  end
end

.make(input = nil, opts = {}, &blk) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/nokogiri.rb', line 28

def make(input = nil, opts = {}, &blk)
  if input
    Nokogiri::XML::Node.new_from_str(input)
  else
    Nokogiri(&blk)
  end
end

.parse(string, url = nil, encoding = nil, options = 32) {|doc| ... } ⇒ Object

Yields:

  • (doc)


13
14
15
16
17
18
19
20
21
22
# File 'lib/nokogiri.rb', line 13

def parse(string, url = nil, encoding = nil, options = 32)
  doc =
    if string =~ /^\s*<[^Hh>]*html/i # Probably html
      Nokogiri::HTML.parse(string, url, encoding, options)
    else
      Nokogiri::XML.parse(string, url, encoding, options)
    end
  yield doc if block_given?
  doc
end

.XML(string) ⇒ Object



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

def XML(string)
  Nokogiri::XML.parse(string)
end