Class Nokogiri::XML::NodeSet
In: lib/nokogiri/ffi/xml/node_set.rb
lib/nokogiri/xml/node_set.rb
ext/nokogiri/xml_sax_parser.c
Parent: Object

A NodeSet contains a list of Nokogiri::XML::Node objects. Typically a NodeSet is return as a result of searching a Document via Nokogiri::XML::Node#css or Nokogiri::XML::Node#xpath

Methods

%   &   -   /   ==   >   []   add_class   after   at   at_css   at_xpath   attr   attribute   before   children   css   delete   dup   each   empty?   filter   first   include?   index   inner_html   inner_text   inspect   last   length   new   pop   push   remove_attr   remove_class   reverse   search   set   shift   slice   text   to_a   to_html   to_s   to_xhtml   to_xml   unlink   wrap   xpath   |  

Included Modules

Enumerable

External Aliases

[] -> slice
push -> <<
unlink -> remove
length -> size
to_a -> to_ary
| -> +

Attributes

document  [RW]  The Document this NodeSet is associated with

Public Class methods

Create a NodeSet with document defaulting to list

Public Instance methods

%(path, ns = document.root ? document.root.namespaces : {})

Alias for at

Set Intersection — Returns a new NodeSet containing nodes common to the two NodeSets.

Difference - returns a new NodeSet that is a copy of this NodeSet, removing each item that also appears in node_set

/(*paths)

Alias for search

Equality — Two NodeSets are equal if the contain the same number of elements and if each element is equal to the corresponding element in the other NodeSet

Search this NodeSet‘s nodes’ immediate children using CSS selector selector

Element reference - returns the node at index, or returns a NodeSet containing nodes starting at start and continuing for length elements, or returns a NodeSet containing nodes specified by range. Negative indices count backward from the end of the node_set (-1 is the last node). Returns nil if the index (or start) are out of range.

Append the class attribute name to all Node objects in the NodeSet.

Insert datum after the last Node in this NodeSet

If path is a string, search this document for path returning the first Node. Otherwise, index in to the array with path.

Search this NodeSet for the first occurrence of CSS rules. Equivalent to css(rules).first See NodeSet#css for more information.

Search this NodeSet for the first occurrence of XPath paths. Equivalent to xpath(paths).first See NodeSet#xpath for more information.

Set the attribute key to value or the return value of blk on all Node objects in the NodeSet.

attribute(key, value = nil, &blk)

Alias for attr

Insert datum before the first Node in this NodeSet

Returns a new NodeSet containing all the children of all the nodes in the NodeSet

Search this NodeSet for css paths

For more information see Nokogiri::XML::Node#css

Delete node from the Nodeset, if it is a member. Returns the deleted node if found, otherwise returns nil.

Duplicate this node set

Iterate over each node, yielding to block

Filter this list for nodes that match expr

Get the first element of the NodeSet.

Returns true if any member of node set equals node.

Returns the index of the first node in self that is == to node. Returns nil if no match is found.

Get the inner html of all contained Node objects

Get the inner text of all contained Node objects

Return a nicely formated string representation

Get the last element of the NodeSet.

Get the length of the node set

Removes the last element from set and returns it, or nil if the set is empty

Append node to the NodeSet.

Remove the attributed named name from all Node objects in the NodeSet

Remove the class attribute name from all Node objects in the NodeSet. If name is nil, remove the class attribute from all Nodes in the NodeSet.

Returns a new NodeSet containing all the nodes in the NodeSet in reverse order

Search this document for paths

For more information see Nokogiri::XML::Node#css and Nokogiri::XML::Node#xpath

set(key, value = nil, &blk)

Alias for attr

Returns the first element of the NodeSet and removes it. Returns nil if the set is empty.

Element reference - returns the node at index, or returns a NodeSet containing nodes starting at start and continuing for length elements, or returns a NodeSet containing nodes specified by range. Negative indices count backward from the end of the node_set (-1 is the last node). Returns nil if the index (or start) are out of range.

text()

Alias for inner_text

Return this list as an Array

Convert this NodeSet to HTML

Convert this NodeSet to a string.

Convert this NodeSet to XHTML

Convert this NodeSet to XML

Unlink this NodeSet and all Node objects it contains from their current context.

Wrap this NodeSet with html or the results of the builder in blk

Search this NodeSet for XPath paths

For more information see Nokogiri::XML::Node#xpath

Returns a new set built by merging the set and the elements of the given set.

[Validate]