Module: Nokogiri
- Defined in:
- lib/nokogiri.rb,
lib/nokogiri/css.rb,
lib/nokogiri/xml.rb,
lib/nokogiri/html.rb,
lib/nokogiri/xslt.rb,
lib/nokogiri/version.rb,
lib/nokogiri/xml/dtd.rb,
lib/nokogiri/css/node.rb,
lib/nokogiri/xml/attr.rb,
lib/nokogiri/xml/node.rb,
lib/nokogiri/xml/text.rb,
lib/nokogiri/xml/cdata.rb,
lib/nokogiri/xml/xpath.rb,
lib/nokogiri/css/parser.rb,
lib/nokogiri/ffi/libxml.rb,
lib/nokogiri/ffi/libxml.rb,
lib/nokogiri/xml/reader.rb,
lib/nokogiri/xml/schema.rb,
lib/nokogiri/ffi/xml/dtd.rb,
lib/nokogiri/xml/builder.rb,
lib/nokogiri/xml/pp/node.rb,
lib/nokogiri/ffi/xml/attr.rb,
lib/nokogiri/ffi/xml/node.rb,
lib/nokogiri/ffi/xml/text.rb,
lib/nokogiri/html/builder.rb,
lib/nokogiri/syntax_error.rb,
lib/nokogiri/xml/document.rb,
lib/nokogiri/xml/node_set.rb,
lib/nokogiri/xml/notation.rb,
lib/nokogiri/xml/relax_ng.rb,
lib/nokogiri/css/tokenizer.rb,
lib/nokogiri/ffi/xml/cdata.rb,
lib/nokogiri/ffi/xml/xpath.rb,
lib/nokogiri/html/document.rb,
lib/nokogiri/xml/namespace.rb,
lib/nokogiri/ffi/xml/reader.rb,
lib/nokogiri/ffi/xml/schema.rb,
lib/nokogiri/xml/sax/parser.rb,
lib/nokogiri/decorators/slop.rb,
lib/nokogiri/ffi/weak_bucket.rb,
lib/nokogiri/ffi/xml/comment.rb,
lib/nokogiri/html/sax/parser.rb,
lib/nokogiri/version_warning.rb,
lib/nokogiri/xml/entity_decl.rb,
lib/nokogiri/xslt/stylesheet.rb,
lib/nokogiri/css/syntax_error.rb,
lib/nokogiri/ffi/io_callbacks.rb,
lib/nokogiri/ffi/xml/document.rb,
lib/nokogiri/ffi/xml/node_set.rb,
lib/nokogiri/ffi/xml/relax_ng.rb,
lib/nokogiri/xml/element_decl.rb,
lib/nokogiri/xml/sax/document.rb,
lib/nokogiri/xml/syntax_error.rb,
lib/nokogiri/css/xpath_visitor.rb,
lib/nokogiri/ffi/html/document.rb,
lib/nokogiri/ffi/xml/namespace.rb,
lib/nokogiri/xml/parse_options.rb,
lib/nokogiri/xml/xpath_context.rb,
lib/nokogiri/ffi/structs/xml_ns.rb,
lib/nokogiri/ffi/xml/sax/parser.rb,
lib/nokogiri/html/entity_lookup.rb,
lib/nokogiri/xml/attribute_decl.rb,
lib/nokogiri/xml/character_data.rb,
lib/nokogiri/ffi/structs/xml_dtd.rb,
lib/nokogiri/ffi/xml/entity_decl.rb,
lib/nokogiri/ffi/xslt/stylesheet.rb,
lib/nokogiri/xml/element_content.rb,
lib/nokogiri/xml/sax/push_parser.rb,
lib/nokogiri/css/generated_parser.rb,
lib/nokogiri/ffi/encoding_handler.rb,
lib/nokogiri/ffi/structs/xml_attr.rb,
lib/nokogiri/ffi/structs/xml_node.rb,
lib/nokogiri/ffi/xml/element_decl.rb,
lib/nokogiri/ffi/xml/syntax_error.rb,
lib/nokogiri/ffi/structs/xml_alloc.rb,
lib/nokogiri/ffi/xml/xpath_context.rb,
lib/nokogiri/xml/document_fragment.rb,
lib/nokogiri/xml/node/save_options.rb,
lib/nokogiri/xml/pp/character_data.rb,
lib/nokogiri/ffi/html/entity_lookup.rb,
lib/nokogiri/ffi/structs/xml_buffer.rb,
lib/nokogiri/ffi/structs/xml_entity.rb,
lib/nokogiri/ffi/structs/xml_schema.rb,
lib/nokogiri/ffi/xml/attribute_decl.rb,
lib/nokogiri/html/document_fragment.rb,
lib/nokogiri/xml/sax/parser_context.rb,
lib/nokogiri/xml/xpath/syntax_error.rb,
lib/nokogiri/css/generated_tokenizer.rb,
lib/nokogiri/ffi/structs/common_node.rb,
lib/nokogiri/ffi/structs/xml_element.rb,
lib/nokogiri/ffi/xml/element_content.rb,
lib/nokogiri/ffi/xml/sax/push_parser.rb,
lib/nokogiri/html/sax/parser_context.rb,
lib/nokogiri/ffi/structs/xml_document.rb,
lib/nokogiri/ffi/structs/xml_node_set.rb,
lib/nokogiri/ffi/structs/xml_notation.rb,
lib/nokogiri/ffi/structs/xml_relax_ng.rb,
lib/nokogiri/ffi/xml/entity_reference.rb,
lib/nokogiri/html/element_description.rb,
lib/nokogiri/ffi/structs/xml_attribute.rb,
lib/nokogiri/ffi/xml/document_fragment.rb,
lib/nokogiri/ffi/structs/html_elem_desc.rb,
lib/nokogiri/ffi/xml/sax/parser_context.rb,
lib/nokogiri/xml/processing_instruction.rb,
lib/nokogiri/ffi/html/sax/parser_context.rb,
lib/nokogiri/ffi/structs/xml_enumeration.rb,
lib/nokogiri/ffi/structs/xml_sax_handler.rb,
lib/nokogiri/ffi/structs/xml_text_reader.rb,
lib/nokogiri/ffi/structs/xslt_stylesheet.rb,
lib/nokogiri/ffi/html/element_description.rb,
lib/nokogiri/ffi/structs/html_entity_desc.rb,
lib/nokogiri/ffi/structs/xml_syntax_error.rb,
lib/nokogiri/ffi/structs/xml_xpath_object.rb,
lib/nokogiri/ffi/structs/xml_xpath_context.rb,
lib/nokogiri/ffi/structs/xml_parser_context.rb,
lib/nokogiri/ffi/xml/processing_instruction.rb,
lib/nokogiri/ffi/structs/xml_element_content.rb,
lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb,
lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb,
lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb,
ext/nokogiri/xml_dtd.c,
ext/nokogiri/nokogiri.c,
ext/nokogiri/xml_attr.c,
ext/nokogiri/xml_node.c,
ext/nokogiri/xml_text.c,
ext/nokogiri/xml_cdata.c,
ext/nokogiri/xml_reader.c,
ext/nokogiri/xml_schema.c,
ext/nokogiri/xml_comment.c,
ext/nokogiri/xml_document.c,
ext/nokogiri/xml_node_set.c,
ext/nokogiri/xml_relax_ng.c,
ext/nokogiri/html_document.c,
ext/nokogiri/xml_namespace.c,
ext/nokogiri/xml_sax_parser.c,
ext/nokogiri/xml_entity_decl.c,
ext/nokogiri/xslt_stylesheet.c,
ext/nokogiri/xml_element_decl.c,
ext/nokogiri/xml_syntax_error.c,
ext/nokogiri/xml_xpath_context.c,
ext/nokogiri/html_entity_lookup.c,
ext/nokogiri/xml_attribute_decl.c,
ext/nokogiri/xml_element_content.c,
ext/nokogiri/xml_sax_push_parser.c,
ext/nokogiri/xml_encoding_handler.c,
ext/nokogiri/xml_entity_reference.c,
ext/nokogiri/xml_document_fragment.c,
ext/nokogiri/xml_sax_parser_context.c,
ext/nokogiri/html_sax_parser_context.c,
ext/nokogiri/html_element_description.c,
ext/nokogiri/xml_processing_instruction.c
Overview
:stopdoc:
Defined Under Namespace
Modules: CSS, Decorators, HTML, IoCallbacks, LibXML, XML, XSLT Classes: EncodingHandler, SyntaxError, WeakBucket
Constant Summary collapse
- VERSION =
The version of Nokogiri you are using
'1.4.2.1'
- VERSION_INFO =
More complete version information about libxml
{}
- LIBXML_PARSER_VERSION =
LibXML.__xmlParserVersion().read_pointer.read_string
- LIBXML_VERSION =
LIBXML_PARSER_VERSION.scan(/^(.*)(..)(..)$/).first.collect{|j|j.to_i}.join(".")
- LIBXML_ICONV_ENABLED =
sigh.
true
Class Method Summary collapse
-
.ffi? ⇒ Boolean
:nodoc:.
-
.HTML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) ⇒ Object
Parse HTML.
-
.is_2_6_16? ⇒ Boolean
:nodoc:.
-
.make(input = nil, opts = {}, &blk) ⇒ Object
Create a new Nokogiri::XML::DocumentFragment.
-
.parse(string, url = nil, encoding = nil, options = nil) {|doc| ... } ⇒ Object
Parse an HTML or XML document.
-
.Slop(*args, &block) ⇒ Object
Parse a document and add the Slop decorator.
-
.uses_libxml? ⇒ Boolean
:nodoc:.
-
.XML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block) ⇒ Object
Parse XML.
-
.XSLT(stylesheet) ⇒ Object
Create a Nokogiri::XSLT::Stylesheet with
stylesheet
.
Class Method Details
.ffi? ⇒ Boolean
:nodoc:
30 31 32 |
# File 'lib/nokogiri/version.rb', line 30 def self.ffi? # :nodoc: uses_libxml? && Nokogiri::VERSION_INFO['libxml']['binding'] == 'ffi' end |
.HTML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) ⇒ Object
Parse HTML. Convenience method for Nokogiri::HTML::Document.parse
12 13 14 |
# File 'lib/nokogiri/html.rb', line 12 def HTML thing, url = nil, encoding = nil, = XML::ParseOptions::DEFAULT_HTML, &block Nokogiri::HTML::Document.parse(thing, url, encoding, , &block) end |
.is_2_6_16? ⇒ Boolean
:nodoc:
34 35 36 |
# File 'lib/nokogiri/version.rb', line 34 def self.is_2_6_16? # :nodoc: Nokogiri::VERSION_INFO['libxml']['loaded'] <= '2.6.16' end |
.make(input = nil, opts = {}, &blk) ⇒ Object
Create a new Nokogiri::XML::DocumentFragment
91 92 93 94 95 96 97 |
# File 'lib/nokogiri.rb', line 91 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) {|doc| ... } ⇒ Object
Parse an HTML or XML document. string
contains the document.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/nokogiri.rb', line 72 def parse string, url = nil, encoding = nil, = nil doc = if string.respond_to?(:read) || string =~ /^\s*<[^Hh>]*html/i # Probably html Nokogiri::HTML( string, url, encoding, || XML::ParseOptions::DEFAULT_HTML ) else Nokogiri::XML(string, url, encoding, || XML::ParseOptions::DEFAULT_XML) end yield doc if block_given? doc end |
.Slop(*args, &block) ⇒ Object
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)
114 115 116 |
# File 'lib/nokogiri.rb', line 114 def Slop(*args, &block) Nokogiri(*args, &block).slop! end |
.uses_libxml? ⇒ Boolean
:nodoc:
26 27 28 |
# File 'lib/nokogiri/version.rb', line 26 def self.uses_libxml? # :nodoc: !Nokogiri::VERSION_INFO['libxml'].nil? end |
.XML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block) ⇒ Object
Parse XML. Convenience method for Nokogiri::XML::Document.parse
32 33 34 |
# File 'lib/nokogiri/xml.rb', line 32 def XML thing, url = nil, encoding = nil, = XML::ParseOptions::DEFAULT_XML, &block Nokogiri::XML::Document.parse(thing, url, encoding, , &block) end |