Module: Nokogiri::XML

Defined in:
lib/nokogiri/xml.rb,
lib/nokogiri/xml/dtd.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/xml/reader.rb,
lib/nokogiri/xml/schema.rb,
lib/nokogiri/xml/builder.rb,
lib/nokogiri/xml/pp/node.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/xml/namespace.rb,
lib/nokogiri/xml/sax/parser.rb,
lib/nokogiri/xml/searchable.rb,
lib/nokogiri/xml/entity_decl.rb,
lib/nokogiri/xml/element_decl.rb,
lib/nokogiri/xml/sax/document.rb,
lib/nokogiri/xml/syntax_error.rb,
lib/nokogiri/xml/parse_options.rb,
lib/nokogiri/xml/xpath_context.rb,
lib/nokogiri/xml/attribute_decl.rb,
lib/nokogiri/xml/character_data.rb,
lib/nokogiri/xml/element_content.rb,
lib/nokogiri/xml/sax/push_parser.rb,
lib/nokogiri/xml/entity_reference.rb,
lib/nokogiri/xml/document_fragment.rb,
lib/nokogiri/xml/node/save_options.rb,
lib/nokogiri/xml/pp/character_data.rb,
lib/nokogiri/xml/sax/parser_context.rb,
lib/nokogiri/xml/xpath/syntax_error.rb,
lib/nokogiri/xml/processing_instruction.rb,
ext/nokogiri/nokogiri.c

Defined Under Namespace

Modules: PP, SAX, Searchable, XPath Classes: Attr, AttributeDecl, Builder, CDATA, CharacterData, Comment, DTD, Document, DocumentFragment, Element, ElementContent, ElementDecl, EntityDecl, EntityReference, Namespace, Node, NodeSet, Notation, ParseOptions, ProcessingInstruction, Reader, RelaxNG, Schema, SyntaxError, Text, XPathContext

Constant Summary collapse

XML_C14N_1_0 =

Original C14N 1.0 spec canonicalization

0
XML_C14N_EXCLUSIVE_1_0 =

Exclusive C14N 1.0 spec canonicalization

1
XML_C14N_1_1 =

C14N 1.1 spec canonicalization

2

Class Method Summary collapse

Class Method Details

.fragment(string) ⇒ Object

Parse a fragment from string in to a NodeSet.



71
72
73
# File 'lib/nokogiri/xml.rb', line 71

def fragment string
  XML::DocumentFragment.parse(string)
end

.parse(thing, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block) ⇒ Object

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



65
66
67
# File 'lib/nokogiri/xml.rb', line 65

def parse thing, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block
  Document.parse(thing, url, encoding, options, &block)
end

.Reader(string_or_io, url = nil, encoding = nil, options = ParseOptions::STRICT) {|options| ... } ⇒ Object

Parse an XML document using the Nokogiri::XML::Reader API. See Nokogiri::XML::Reader for mor information

Yields:

  • (options)


51
52
53
54
55
56
57
58
59
60
61
# File 'lib/nokogiri/xml.rb', line 51

def Reader string_or_io, url = nil, encoding = nil, options = ParseOptions::STRICT

  options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
  # Give the options to the user
  yield options if block_given?

  if string_or_io.respond_to? :read
    return Reader.from_io(string_or_io, url, encoding, options.to_i)
  end
  Reader.from_memory(string_or_io, url, encoding, options.to_i)
end

.RelaxNG(string_or_io, options = ParseOptions::DEFAULT_SCHEMA) ⇒ Object

Create a new Nokogiri::XML::RelaxNG document from string_or_io. See Nokogiri::XML::RelaxNG for an example.



8
9
10
# File 'lib/nokogiri/xml/relax_ng.rb', line 8

def RelaxNG(string_or_io, options = ParseOptions::DEFAULT_SCHEMA)
  RelaxNG.new(string_or_io, options)
end

.Schema(string_or_io, options = ParseOptions::DEFAULT_SCHEMA) ⇒ Object

Create a new Nokogiri::XML::Schema object using a string_or_io object.



8
9
10
# File 'lib/nokogiri/xml/schema.rb', line 8

def Schema(string_or_io, options = ParseOptions::DEFAULT_SCHEMA)
  Schema.new(string_or_io, options)
end