### Home Classes Methods

### In Files

- lib/nokogiri/xml.rb
- lib/nokogiri/decorators/slop.rb
- lib/nokogiri/html.rb
- lib/nokogiri/css/node.rb
- lib/nokogiri/css/syntax_error.rb
- lib/nokogiri/css/tokenizer.rb
- lib/nokogiri/css/parser.rb
- lib/nokogiri/css/xpath_visitor.rb
- lib/nokogiri/css/parser_extras.rb
- lib/nokogiri/xml/parse_options.rb
- lib/nokogiri/xml/pp/node.rb
- lib/nokogiri/xml/pp/character_data.rb
- lib/nokogiri/xml/element_decl.rb
- lib/nokogiri/xml/text.rb
- lib/nokogiri/xml/node_set.rb
- lib/nokogiri/xml/builder.rb
- lib/nokogiri/xml/document.rb
- lib/nokogiri/xml/document_fragment.rb
- lib/nokogiri/xml/dtd.rb
- lib/nokogiri/xml/schema.rb
- lib/nokogiri/xml/relax_ng.rb
- lib/nokogiri/xml/xpath_context.rb
- lib/nokogiri/xml/processing_instruction.rb
- lib/nokogiri/xml/namespace.rb
- lib/nokogiri/xml/notation.rb
- lib/nokogiri/xml/reader.rb
- lib/nokogiri/xml/character_data.rb
- lib/nokogiri/xml/node/save_options.rb
- lib/nokogiri/xml/element_content.rb
- lib/nokogiri/xml/entity_decl.rb
- lib/nokogiri/xml/syntax_error.rb
- lib/nokogiri/xml/attr.rb
- lib/nokogiri/xml/node.rb
- lib/nokogiri/xml/xpath.rb
- lib/nokogiri/xml/attribute_decl.rb
- lib/nokogiri/xml/cdata.rb
- lib/nokogiri/xml/sax/parser.rb
- lib/nokogiri/xml/sax/document.rb
- lib/nokogiri/xml/sax/push_parser.rb
- lib/nokogiri/xml/sax/parser_context.rb
- lib/nokogiri/xml/xpath/syntax_error.rb
- lib/nokogiri/xslt/stylesheet.rb
- lib/nokogiri/css.rb
- lib/nokogiri/html/sax/parser.rb
- lib/nokogiri/html/sax/push_parser.rb
- lib/nokogiri/html/sax/parser_context.rb
- lib/nokogiri/html/builder.rb
- lib/nokogiri/html/element_description_defaults.rb
- lib/nokogiri/html/document.rb
- lib/nokogiri/html/document_fragment.rb
- lib/nokogiri/html/entity_lookup.rb
- lib/nokogiri/html/element_description.rb
- lib/nokogiri/syntax_error.rb
- lib/nokogiri/version.rb
- lib/nokogiri/xslt.rb
- lib/nokogiri.rb
- ext/nokogiri/html_document.c
- ext/nokogiri/html_element_description.c
- ext/nokogiri/html_entity_lookup.c
- ext/nokogiri/html_sax_parser_context.c
- ext/nokogiri/html_sax_push_parser.c
- ext/nokogiri/nokogiri.c
- ext/nokogiri/xml_attr.c
- ext/nokogiri/xml_attribute_decl.c
- ext/nokogiri/xml_cdata.c
- ext/nokogiri/xml_comment.c
- ext/nokogiri/xml_document.c
- ext/nokogiri/xml_document_fragment.c
- ext/nokogiri/xml_dtd.c
- ext/nokogiri/xml_element_content.c
- ext/nokogiri/xml_element_decl.c
- ext/nokogiri/xml_encoding_handler.c
- ext/nokogiri/xml_entity_decl.c
- ext/nokogiri/xml_entity_reference.c
- ext/nokogiri/xml_namespace.c
- ext/nokogiri/xml_node.c
- ext/nokogiri/xml_node_set.c
- ext/nokogiri/xml_processing_instruction.c
- ext/nokogiri/xml_reader.c
- ext/nokogiri/xml_relax_ng.c
- ext/nokogiri/xml_sax_parser.c
- ext/nokogiri/xml_sax_parser_context.c
- ext/nokogiri/xml_sax_push_parser.c
- ext/nokogiri/xml_schema.c
- ext/nokogiri/xml_syntax_error.c
- ext/nokogiri/xml_text.c
- ext/nokogiri/xml_xpath_context.c
- ext/nokogiri/xslt_stylesheet.c

### Namespace

- MODULE Nokogiri::CSS
- MODULE Nokogiri::Decorators
- MODULE Nokogiri::HTML
- MODULE Nokogiri::XML
- MODULE Nokogiri::XSLT
- CLASS Nokogiri::EncodingHandler
- CLASS Nokogiri::SyntaxError

### Methods

- ::HTML
- ::Slop
- ::XML
- ::XSLT
- ::make
- ::parse

### Files

- CHANGELOG.ja.rdoc
- CHANGELOG.rdoc
- C_CODING_STYLE.rdoc
- Manifest.txt
- README.ja.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Nokogiri
- Nokogiri::CSS
- Nokogiri::CSS::Node
- Nokogiri::CSS::Parser
- Nokogiri::CSS::SyntaxError
- Nokogiri::CSS::Tokenizer
- Nokogiri::CSS::Tokenizer::ScanError
- Nokogiri::Decorators
- Nokogiri::Decorators::Slop
- Nokogiri::EncodingHandler
- Nokogiri::HTML
- Nokogiri::HTML::Builder
- Nokogiri::HTML::Document
- Nokogiri::HTML::Document::EncodingReader
- Nokogiri::HTML::Document::EncodingReader::JumpSAXHandler
- Nokogiri::HTML::DocumentFragment
- Nokogiri::HTML::ElementDescription
- Nokogiri::HTML::EntityDescription
- Nokogiri::HTML::EntityLookup
- Nokogiri::HTML::SAX
- Nokogiri::HTML::SAX::Parser
- Nokogiri::HTML::SAX::ParserContext
- Nokogiri::HTML::SAX::PushParser
- Nokogiri::SyntaxError
- Nokogiri::XML
- Nokogiri::XML::Attr
- Nokogiri::XML::AttributeDecl
- Nokogiri::XML::Builder
- Nokogiri::XML::CDATA
- Nokogiri::XML::CharacterData
- Nokogiri::XML::Comment
- Nokogiri::XML::DTD
- Nokogiri::XML::Document
- Nokogiri::XML::DocumentFragment
- Nokogiri::XML::Element
- Nokogiri::XML::ElementContent
- Nokogiri::XML::ElementDecl
- Nokogiri::XML::EntityDecl
- Nokogiri::XML::EntityReference
- Nokogiri::XML::Namespace
- Nokogiri::XML::Node
- Nokogiri::XML::Node::SaveOptions
- Nokogiri::XML::NodeSet
- Nokogiri::XML::Notation
- Nokogiri::XML::PP
- Nokogiri::XML::PP::CharacterData
- Nokogiri::XML::PP::Node
- Nokogiri::XML::ParseOptions
- Nokogiri::XML::ProcessingInstruction
- Nokogiri::XML::Reader
- Nokogiri::XML::RelaxNG
- Nokogiri::XML::SAX
- Nokogiri::XML::SAX::Document
- Nokogiri::XML::SAX::Parser
- Nokogiri::XML::SAX::Parser::Attribute
- Nokogiri::XML::SAX::ParserContext
- Nokogiri::XML::SAX::PushParser
- Nokogiri::XML::Schema
- Nokogiri::XML::SyntaxError
- Nokogiri::XML::Text
- Nokogiri::XML::XPath
- Nokogiri::XML::XPath::SyntaxError
- Nokogiri::XML::XPathContext
- Nokogiri::XSLT
- Nokogiri::XSLT::Stylesheet
- XSD
- XSD::XMLParser
- XSD::XMLParser::Nokogiri
- Object

No matching classes.

# Nokogiri

Nokogiri parses and searches XML/HTML very quickly, and also has correctly implemented CSS3 selector support as well as XPath support.

Parsing a document returns either a Nokogiri::XML::Document, or a Nokogiri::HTML::Document depending on the kind of document you parse.

Here is an example:

    require 'nokogiri'
    require 'open-uri'

    # Get a Nokogiri::HTML:Document for the page we’re interested in...

    doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))

    # Do funky things with it using Nokogiri::XML::Node methods...

    ####
    # Search for nodes by css
    doc.css('h3.r a.l').each do |link|
      puts link.content
    end

See Nokogiri::XML::Node#css for more information about CSS searching. See Nokogiri::XML::Node#xpath for more information about XPath searching.

### Constants

VERSION

  The version of Nokogiri you are using

VERSION_INFO

  More complete version information about libxml

### Public Class Methods

HTML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) click to toggle source

Parse HTML. Convenience method for Nokogiri::HTML::Document.parse

    # File lib/nokogiri/html.rb, line 14
    def HTML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block
      Nokogiri::HTML::Document.parse(thing, url, encoding, options, &block)
    end

Slop(*args, &block) click to toggle source

Parse a document and add the Slop decorator. The Slop decorator implements method_missing such that methods may be used instead of CSS or XPath. For example:

    doc = Nokogiri::Slop(<<-eohtml)
      <html>
        <body>
          <p>first</p>
          <p>second</p>
        </body>
      </html>
    eohtml
    assert_equal('second', doc.html.body.p[1].text)

    # File lib/nokogiri.rb, line 108
    def Slop(*args, &block)
      Nokogiri(*args, &block).slop!
    end

XML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block) click to toggle source

Parse XML. Convenience method for Nokogiri::XML::Document.parse

    # File lib/nokogiri/xml.rb, line 32
    def XML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block
      Nokogiri::XML::Document.parse(thing, url, encoding, options, &block)
    end

XSLT(stylesheet, modules = {}) click to toggle source

Create a Nokogiri::XSLT::Stylesheet with `stylesheet`.

Example:

    xslt = Nokogiri::XSLT(File.read(ARGV[0]))

    # File lib/nokogiri/xslt.rb, line 12
    def XSLT stylesheet, modules = {}
      XSLT.parse(stylesheet, modules)
    end

make(input = nil, opts = {}) click to toggle source

Create a new Nokogiri::XML::DocumentFragment

    # File lib/nokogiri.rb, line 85
    def make input = nil, opts = {}, &blk
      if input
        Nokogiri::HTML.fragment(input).children.first
      else
        Nokogiri(&blk)
      end
    end

parse(string, url = nil, encoding = nil, options = nil) click to toggle source

Parse an HTML or XML document. `string` contains the document.

    # File lib/nokogiri.rb, line 66
    def parse string, url = nil, encoding = nil, options = nil
      doc =
        if string.respond_to?(:read) ||
          string =~ /^\s*<[^Hh>]*html/ # Probably html
          Nokogiri.HTML(
            string,
            url,
            encoding, options || XML::ParseOptions::DEFAULT_HTML
          )
        else
          Nokogiri.XML(string, url, encoding,
                        options || XML::ParseOptions::DEFAULT_XML)
        end
      yield doc if block_given?
      doc
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.