class Nokogiri::XML::Node
You may search this node’s subtree using {#xpath} and {#css}
parsers, etc.
properly-escaped markup</b>, meaning that it’s suitable for consumption by browsers,
* {#to_s}, {#to_xml}, {#to_html}, {#inner_html}: These methods will all emit<br><br>that any sanitizing will likely be un-done in the output.<br>meaning that entities will be replaced (e.g., “<” will be replaced with “<”), meaning<br>* {#content}, {#text}, {#inner_text}, {#to_str}: These methods will all <b>emit plaintext,
its subtree), there are a few methods you might want to use:
When printing or otherwise emitting a document or a node (and
* {#previous}
* {#next}
* {#children}
* {#parent}
tree. For navigating your tree, see:
{Nokogiri::XML::Node} also has methods that let you move around your
See the method group entitled “Working With Node Attributes” for the full set of methods.
node.to_html # => “<a href="#foo" id="link" class="green">link</a>”<br>node = ‘green’ # => “green”
node.values # => [“#foo”, “link”]
node.keys # => [“href”, “id”]<br>node # => “#foo”
node.to_html # => “<a href="#foo" id="link">link</a>”
node = Nokogiri::XML::DocumentFragment.parse(“<a href=‘#foo’ id=‘link’>link</a>”).at_css(“a”)
example:
tags. A {Nokogiri::XML::Node} may be treated similarly to a hash with regard to attributes. For
{Nokogiri::XML::Node} is your window to the fun filled world of dealing with XML and HTML
#
def <<(node_or_tags)
Returns self, to support chaining of calls (e.g., root << child1 << child2)
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Add +node_or_tags+ as a child of this Node.
##
def <<(node_or_tags) add_child node_or_tags self end
def <=>(other)
Compare two Node objects with respect to their Document. Nodes from
##
def <=>(other) return nil unless other.is_a?(Nokogiri::XML::Node) return nil unless document == other.document compare other end
def ==(other)
##
def ==(other) return false unless other return false unless other.respond_to?(:pointer_id) pointer_id == other.pointer_id end
def >(selector)
##
def >(selector) ns = document.root.namespaces xpath CSS.xpath_for(selector, :prefix => "./", :ns => ns).first end
def [](name)
##
def [](name) get(name.to_s) end
def []=(name, value)
##
def []=(name, value) set name.to_s, value.to_s end
def accept(visitor)
##
def accept(visitor) visitor.visit(self) end
def add_child(node_or_tags)
Returns the reparented node (if +node_or_tags+ is a Node), or NodeSet (if +node_or_tags+ is a DocumentFragment, NodeSet, or string).
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Add +node_or_tags+ as a child of this Node.
##
def add_child(node_or_tags) node_or_tags = coerce(node_or_tags) if node_or_tags.is_a?(XML::NodeSet) node_or_tags.each { |n| add_child_node_and_reparent_attrs n } else add_child_node_and_reparent_attrs node_or_tags end node_or_tags end
def add_child_node_and_reparent_attrs(node)
def add_child_node_and_reparent_attrs(node) add_child_node node node.attribute_nodes.find_all { |a| a.name =~ /:/ }.each do |attr_node| attr_node.remove node[attr_node.name] = attr_node.value end end
def add_class(names)
- Example: Ensure that a +Node+ has CSS classes "section" and "header", via an Array argument. -
Example: Ensure that a +Node+ has CSS classes "section" and "header", via a String argument. -
Example: Ensure that a +Node+ has CSS class "section" -
Returns:
-
(Node)- Returns +self+ for ease of chaining method calls.
Parameters:
-
names(String, Array) --
Other tags:
- See: #remove_class -
See: #append_class -
See: #classes -
See: #kwattr_add -
def add_class(names) kwattr_add("class", names) end
def add_next_sibling(node_or_tags)
Returns the reparented node (if +node_or_tags+ is a Node), or NodeSet (if +node_or_tags+ is a DocumentFragment, NodeSet, or string).
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Insert +node_or_tags+ after this Node (as a sibling).
##
def add_next_sibling(node_or_tags) raise ArgumentError.new("A document may not have multiple root nodes.") if (parent && parent.document?) && !(node_or_tags.comment? || node_or_tags.processing_instruction?) add_sibling :next, node_or_tags end
def add_previous_sibling(node_or_tags)
Returns the reparented node (if +node_or_tags+ is a Node), or NodeSet (if +node_or_tags+ is a DocumentFragment, NodeSet, or string).
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Insert +node_or_tags+ before this Node (as a sibling).
##
def add_previous_sibling(node_or_tags) raise ArgumentError.new("A document may not have multiple root nodes.") if (parent && parent.document?) && !(node_or_tags.comment? || node_or_tags.processing_instruction?) add_sibling :previous, node_or_tags end
def add_sibling(next_or_previous, node_or_tags)
def add_sibling(next_or_previous, node_or_tags) raise("Cannot add sibling to a node with no parent") unless parent impl = (next_or_previous == :next) ? :add_next_sibling_node : :add_previous_sibling_node iter = (next_or_previous == :next) ? :reverse_each : :each node_or_tags = parent.coerce(node_or_tags) if node_or_tags.is_a?(XML::NodeSet) if text? pivot = Nokogiri::XML::Node.new "dummy", document send impl, pivot else pivot = self end node_or_tags.send(iter) { |n| pivot.send impl, n } pivot.unlink if text? else send impl, node_or_tags end node_or_tags end
def after(node_or_tags)
Returns self, to support chaining of calls.
+node_or_tags+ can be a Nokogiri::XML::Node, a Nokogiri::XML::DocumentFragment, or a string containing markup.
Insert +node_or_tags+ after this node (as a sibling).
###
def after(node_or_tags) add_next_sibling node_or_tags self end
def ancestors(selector = nil)
Get a list of ancestor Node for this Node. If +selector+ is given,
##
def ancestors(selector = nil) return NodeSet.new(document) unless respond_to?(:parent) return NodeSet.new(document) unless parent parents = [parent] while parents.last.respond_to?(:parent) break unless ctx_parent = parents.last.parent parents << ctx_parent end return NodeSet.new(document, parents) unless selector root = parents.last search_results = root.search(selector) NodeSet.new(document, parents.find_all { |parent| search_results.include?(parent) }) end
def append_class(names)
- Example: Append "section" and "header" to a +Node+'s CSS +class+ attribute, via an Array argument. -
Example: Append "section" and "header" to a +Node+'s CSS +class+ attribute, via a String argument. -
Example: Append "section" to a +Node+'s CSS +class+ attriubute -
Returns:
-
(Node)- Returns +self+ for ease of chaining method calls.
Parameters:
-
names(String, Array) --
Other tags:
- See: #remove_class -
See: #add_class -
See: #classes -
See: #kwattr_append -
def append_class(names) kwattr_append("class", names) end
def attributes
If you need to distinguish attributes with the same name, with different namespaces
representing the attribute.
the attribute name without any namespace, the value is a Nokogiri::XML::Attr
Returns a hash containing the node's attributes. The key is
###
def attributes attribute_nodes.each_with_object({}) do |node, hash| hash[node.node_name] = node end end
def before(node_or_tags)
Returns self, to support chaining of calls.
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Insert +node_or_tags+ before this node (as a sibling).
###
def before(node_or_tags) add_previous_sibling node_or_tags self end
def canonicalize(mode = XML::XML_C14N_1_0, inclusive_namespaces = nil, with_comments = false)
def canonicalize(mode = XML::XML_C14N_1_0, inclusive_namespaces = nil, with_comments = false) c14n_root = self document.canonicalize(mode, inclusive_namespaces, with_comments) do |node, parent| tn = node.is_a?(XML::Node) ? node : parent tn == c14n_root || tn.ancestors.include?(c14n_root) end end
def cdata?
def cdata? type == CDATA_SECTION_NODE end
def children=(node_or_tags)
Returns the reparented node (if +node_or_tags+ is a Node), or NodeSet (if +node_or_tags+ is a DocumentFragment, NodeSet, or string).
+node_or_tags+ can be a Nokogiri::XML::Node, a Nokogiri::XML::DocumentFragment, or a string containing markup.
Set the inner html for this Node +node_or_tags+
###
def children=(node_or_tags) node_or_tags = coerce(node_or_tags) children.unlink if node_or_tags.is_a?(XML::NodeSet) node_or_tags.each { |n| add_child_node_and_reparent_attrs n } else add_child_node_and_reparent_attrs node_or_tags end node_or_tags end
def classes
-
(Array-)
Other tags:
- See: #remove_class -
See: #append_class -
See: #add_class -
See: #kwattr_values -
def classes kwattr_values("class") end
def coerce(data)
def coerce(data) case data when XML::NodeSet return data when XML::DocumentFragment return data.children when String return fragment(data).children when Document, XML::Attr # unacceptable when XML::Node return data end raise ArgumentError, <<-EOERR es a Node, NodeSet or String argument, and cannot accept a #{data.class}. robably want to select a node from the Document with at() or search(), or create a new Node via Node.new().) EOERR end
def comment?
def comment? type == COMMENT_NODE end
def content=(string)
###
def content=(string) self.native_content = encode_special_chars(string.to_s) end
def css_path
def css_path path.split(/\//).map { |part| part.length == 0 ? nil : part.gsub(/\[(\d+)\]/, ':nth-of-type(\1)') }.compact.join(" > ") end
def decorate!
##
def decorate! document.decorate(self) end
def default_namespace=(url)
now show up in #attributes, but when this node is serialized to XML an
present in parsed XML. A default namespace set with this method will
The consequence is as an xmlns attribute with supplied argument were
Adds a default namespace supplied as a string +url+ href, to self.
##
def default_namespace=(url) add_namespace_definition(nil, url) end
def description
Fetch the Nokogiri::HTML4::ElementDescription for this node. Returns
##
def description return nil if document.xml? Nokogiri::HTML4::ElementDescription[name] end
def do_xinclude(options = XML::ParseOptions::DEFAULT_XML)
Nokogiri::XML::ParseOptions object initialized from +options+, will be
Do xinclude substitution on the subtree below node. If given a block, a
##
def do_xinclude(options = XML::ParseOptions::DEFAULT_XML) options = Nokogiri::XML::ParseOptions.new(options) if Integer === options # give options to user yield options if block_given? # call c extension process_xincludes(options.to_i) end
def document?
def document? is_a? XML::Document end
def each
##
def each attribute_nodes.each { |node| yield [node.node_name, node.value] } end
def element?
def element? type == ELEMENT_NODE end
def fragment(tags)
Create a DocumentFragment containing +tags+ that is relative to _this_
##
def fragment(tags) type = document.html? ? Nokogiri::HTML : Nokogiri::XML type::DocumentFragment.new(document, tags, self) end
def fragment?
def fragment? type == DOCUMENT_FRAG_NODE end
def html?
def html? type == HTML_DOCUMENT_NODE end
def initialize(name, document)
- See: Nokogiri::XML::Node.new -
Returns:
-
(Nokogiri::XML::Node)-
Other tags:
- Yieldparam: node -
Parameters:
-
document(Nokogiri::XML::Document) -- -
name(String) --
def initialize(name, document) # This is intentionally empty. end
def inner_html(*args)
def inner_html(*args) children.map { |x| x.to_html(*args) }.join end
def inner_html=(node_or_tags)
Returns self.
+node_or_tags+ can be a Nokogiri::XML::Node, a Nokogiri::XML::DocumentFragment, or a string containing markup.
Set the inner html for this Node to +node_or_tags+
###
def inner_html=(node_or_tags) self.children = node_or_tags self end
def inspect_attributes
def inspect_attributes [:name, :namespace, :attribute_nodes, :children] end
def keys
##
def keys attribute_nodes.map(&:node_name) end
def keywordify(keywords)
def keywordify(keywords) case keywords when Enumerable return keywords when String return keywords.scan(/\S+/) else raise ArgumentError.new("Keyword attributes must be passed as either a String or an Enumerable, but received #{keywords.class}") end end
def kwattr_add(attribute_name, keywords)
- Since: - v1.11.0
Other tags:
- Example: Ensure that a +Node+ has "nofollow" and "noreferrer" in its +rel+ attribute, via an Array argument. -
Example: Ensure that a +Node+ has "nofollow" and "noreferrer" in its +rel+ attribute, via a String argument. -
Example: Ensure that a +Node+ has "nofollow" in its +rel+ attribute. -
Returns:
-
(Node)- Returns +self+ for ease of chaining method calls.
Parameters:
-
keywords(String, Array) -- -
attribute_name(String) -- The name of the keyword attribute to be modified.
Other tags:
- See: #kwattr_remove -
See: #kwattr_append -
See: #kwattr_values -
See: #add_class -
def kwattr_add(attribute_name, keywords) keywords = keywordify(keywords) current_kws = kwattr_values(attribute_name) new_kws = (current_kws + (keywords - current_kws)).join(" ") set_attribute(attribute_name, new_kws) self end
def kwattr_append(attribute_name, keywords)
- Since: - v1.11.0
Other tags:
- Example: Append "nofollow" and "noreferrer" to the +rel+ attribute, via an Array argument. -
Example: Append "nofollow" and "noreferrer" to the +rel+ attribute, via a String argument. -
Example: Append "nofollow" to the +rel+ attribute. -
Returns:
-
(Node)- Returns +self+ for ease of chaining method calls.
Parameters:
-
keywords(String, Array) -- -
attribute_name(String) -- The name of the keyword attribute to be modified.
Other tags:
- See: #kwattr_remove -
See: #kwattr_add -
See: #kwattr_values -
See: #append_class -
def kwattr_append(attribute_name, keywords) keywords = keywordify(keywords) current_kws = kwattr_values(attribute_name) new_kws = (current_kws + keywords).join(" ") set_attribute(attribute_name, new_kws) self end
def kwattr_remove(attribute_name, keywords)
- Since: - v1.11.0
Returns:
-
(Node)- Returns +self+ for ease of chaining method calls.
Parameters:
-
keywords(String, Array) -- -
attribute_name(String) -- The name of the keyword attribute to be modified.
Other tags:
- See: #kwattr_append -
See: #kwattr_add -
See: #kwattr_values -
See: #remove_class -
def kwattr_remove(attribute_name, keywords) if keywords.nil? remove_attribute(attribute_name) return self end keywords = keywordify(keywords) current_kws = kwattr_values(attribute_name) new_kws = current_kws - keywords if new_kws.empty? remove_attribute(attribute_name) else set_attribute(attribute_name, new_kws.join(" ")) end self end
def kwattr_values(attribute_name)
- Since: - v1.11.0
Returns:
-
(Array-)
Parameters:
-
attribute_name(String) -- The name of the keyword attribute to be inspected.
Other tags:
- See: #kwattr_remove -
See: #kwattr_append -
See: #kwattr_add -
See: #classes -
def kwattr_values(attribute_name) keywordify(get_attribute(attribute_name) || []) end
def matches?(selector)
##
def matches?(selector) ancestors.last.search(selector).include?(self) end
def namespace=(ns)
for this node. You probably want #default_namespace= instead, or perhaps
a Namespace added this way will NOT be serialized as an xmlns attribute
"xmlns=" attribute in XML source), as a Namespace object +ns+. Note that
Set the default namespace on this node (as would be defined with an
##
def namespace=(ns) return set_namespace(ns) unless ns unless Nokogiri::XML::Namespace === ns raise TypeError, "#{ns.class} can't be coerced into Nokogiri::XML::Namespace" end if ns.document != document raise ArgumentError, "namespace must be declared on the same document" end set_namespace ns end
def namespaces
default namespaces set on ancestor will NOT be, even if self
set on self will be included with key "xmlns". However,
such as "xmlns:prefix", not just the prefix. Default namespace
XML attributes that would be used to define this namespace,
attribute-name/value pairs. Note that the keys in this hash
element directly or any ancestor node -- as a Hash of
Returns namespaces in scope for self -- those defined on self
This method returns the same namespaces as #namespace_scopes.
node and its ancestors.
Returns a Hash of +{prefix => value}+ for all namespaces on this
##
def namespaces namespace_scopes.each_with_object({}) do |ns, hash| prefix = ns.prefix key = prefix ? "xmlns:#{prefix}" : "xmlns" hash[key] = ns.href end end
def parent=(parent_node)
##
def parent=(parent_node) parent_node.add_child(self) parent_node end
def parse(string_or_io, options = nil)
*this* node. Returns a XML::NodeSet containing the nodes parsed from
Parse +string_or_io+ as a document fragment within the context of
##
def parse(string_or_io, options = nil) ## # When the current node is unparented and not an element node, use the # document as the parsing context instead. Otherwise, the in-context # parser cannot find an element or a document node. # Document Fragments are also not usable by the in-context parser. if !element? && !document? && (!parent || parent.fragment?) return document.parse(string_or_io, options) end options ||= (document.html? ? ParseOptions::DEFAULT_HTML : ParseOptions::DEFAULT_XML) if Integer === options options = Nokogiri::XML::ParseOptions.new(options) end # Give the options to the user yield options if block_given? contents = string_or_io.respond_to?(:read) ? string_or_io.read : string_or_io return Nokogiri::XML::NodeSet.new(document) if contents.empty? # libxml2 does not obey the `recover` option after encountering errors during `in_context` # parsing, and so this horrible hack is here to try to emulate recovery behavior. # # Unfortunately, this means we're no longer parsing "in context" and so namespaces that # would have been inherited from the context node won't be handled correctly. This hack was # written in 2010, and I regret it, because it's silently degrading functionality in a way # that's not easily prevented (or even detected). # # I think preferable behavior would be to either: # # a. add an error noting that we "fell back" and pointing the user to turning off the `recover` option # b. don't recover, but raise a sensible exception # # For context and background: https://github.com/sparklemotion/nokogiri/issues/313 # FIXME bug report: https://github.com/sparklemotion/nokogiri/issues/2092 error_count = document.errors.length node_set = in_context(contents, options.to_i) if (node_set.empty? && (document.errors.length > error_count)) if options.recover? fragment = Nokogiri::HTML4::DocumentFragment.parse contents node_set = fragment.children else raise document.errors[error_count] end end node_set end
def prepend_child(node_or_tags)
Returns the reparented node (if +node_or_tags+ is a Node), or NodeSet (if +node_or_tags+ is a DocumentFragment, NodeSet, or string).
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Add +node_or_tags+ as the first child of this Node.
##
def prepend_child(node_or_tags) if first = children.first # Mimic the error add_child would raise. raise RuntimeError, "Document already has a root node" if document? && !(node_or_tags.comment? || node_or_tags.processing_instruction?) first.__send__(:add_sibling, :previous, node_or_tags) else add_child(node_or_tags) end end
def processing_instruction?
def processing_instruction? type == PI_NODE end
def read_only?
##
def read_only? # According to gdome2, these are read-only node types [NOTATION_NODE, ENTITY_NODE, ENTITY_DECL].include?(type) end
def remove_attribute(name)
##
def remove_attribute(name) attr = attributes[name].remove if key? name clear_xpath_context if Nokogiri.jruby? attr end
def remove_class(names = nil)
-
(Node)- Returns +self+ for ease of chaining method calls.
Parameters:
-
names(String, Array) --
Other tags:
- See: #append_class -
See: #add_class -
See: #classes -
See: #kwattr_remove -
def remove_class(names = nil) kwattr_remove("class", names) end
def replace(node_or_tags)
Returns the reparented node (if +node_or_tags+ is a Node), or NodeSet (if +node_or_tags+ is a DocumentFragment, NodeSet, or string).
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Replace this Node with +node_or_tags+.
###
def replace(node_or_tags) raise("Cannot replace a node with no parent") unless parent # We cannot replace a text node directly, otherwise libxml will return # an internal error at parser.c:13031, I don't know exactly why # libxml is trying to find a parent node that is an element or document # so I can't tell if this is bug in libxml or not. issue #775. if text? replacee = Nokogiri::XML::Node.new "dummy", document add_previous_sibling_node replacee unlink return replacee.replace node_or_tags end node_or_tags = parent.coerce(node_or_tags) if node_or_tags.is_a?(XML::NodeSet) node_or_tags.each { |n| add_previous_sibling n } unlink else replace_node node_or_tags end node_or_tags end
def serialize(*args, &block)
end
config.format.as_xml
node.serialize(:encoding => 'UTF-8') do |config|
or
node.serialize(:encoding => 'UTF-8', :save_with => FORMAT | AS_XML)
These two statements are equivalent:
block. See SaveOptions.
Serialize Node using +options+. Save options can also be set using a
##
def serialize(*args, &block) options = args.first.is_a?(Hash) ? args.shift : { :encoding => args[0], :save_with => args[1], } encoding = options[:encoding] || document.encoding options[:encoding] = encoding outstring = String.new outstring.force_encoding(Encoding.find(encoding || "utf-8")) io = StringIO.new(outstring) write_to io, options, &block io.string end
def swap(node_or_tags)
Returns self, to support chaining of calls.
+node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
Swap this Node for +node_or_tags+
###
def swap(node_or_tags) replace node_or_tags self end
def text?
def text? type == TEXT_NODE end
def to_format(save_option, options)
def to_format(save_option, options) return dump_html if USING_LIBXML_WITH_BROKEN_SERIALIZATION options[:save_with] = save_option unless options[:save_with] serialize(options) end
def to_html(options = {})
See Node#write_to for a list of +options+. For formatted output,
doc.to_html
Serialize this Node to HTML
##
def to_html(options = {}) to_format SaveOptions::DEFAULT_HTML, options end
def to_s
Turn this node in to a string. If the document is HTML, this method
##
def to_s document.xml? ? to_xml : to_html end
def to_xhtml(options = {})
doc.to_xhtml(:indent => 5, :encoding => 'UTF-8')
Serialize this Node to XHTML using +options+
##
def to_xhtml(options = {}) to_format SaveOptions::DEFAULT_XHTML, options end
def to_xml(options = {})
doc.to_xml(:indent => 5, :encoding => 'UTF-8')
Serialize this Node to XML using +options+
##
def to_xml(options = {}) options[:save_with] ||= SaveOptions::DEFAULT_XML serialize(options) end
def traverse(&block)
###
def traverse(&block) children.each { |j| j.traverse(&block) } block.call(self) end
def value?(value)
##
def value?(value) values.include? value end
def values
##
def values attribute_nodes.map(&:value) end
def wrap(html)
Add html around this node
##
def wrap(html) new_parent = document.parse(html).first add_next_sibling(new_parent) new_parent.add_child(self) self end
def write_format_to(save_option, io, options)
def write_format_to(save_option, io, options) return (io << dump_html) if USING_LIBXML_WITH_BROKEN_SERIALIZATION options[:save_with] ||= save_option write_to io, options end
def write_html_to(io, options = {})
Write Node as HTML to +io+ with +options+
##
def write_html_to(io, options = {}) write_format_to SaveOptions::DEFAULT_HTML, io, options end
def write_to(io, *options)
node.write_to(io, :indent_text => '-', :indent => 2)
To save indented with two dashes:
node.write_to(io, :encoding => 'UTF-8', :indent => 2)
To save with UTF-8 indented twice:
* +:save_with+ a combination of SaveOptions constants.
* +:indent+ the number of +:indent_text+ to use, defaults to 2
* +:indent_text+ the indentation text, defaults to one space
* +:encoding+ for changing the encoding
this method. Valid options are:
Write Node to +io+ with +options+. +options+ modify the output of
##
def write_to(io, *options) options = options.first.is_a?(Hash) ? options.shift : {} encoding = options[:encoding] || options[0] if Nokogiri.jruby? save_options = options[:save_with] || options[1] indent_times = options[:indent] || 0 else save_options = options[:save_with] || options[1] || SaveOptions::FORMAT indent_times = options[:indent] || 2 end indent_text = options[:indent_text] || " " # Any string times 0 returns an empty string. Therefore, use the same # string instead of generating a new empty string for every node with # zero indentation. indentation = indent_times.zero? ? "" : (indent_text * indent_times) config = SaveOptions.new(save_options.to_i) yield config if block_given? native_write_to(io, encoding, indentation, config.options) end
def write_xhtml_to(io, options = {})
Write Node as XHTML to +io+ with +options+
##
def write_xhtml_to(io, options = {}) write_format_to SaveOptions::DEFAULT_XHTML, io, options end
def write_xml_to(io, options = {})
doc.write_xml_to io, :encoding => 'UTF-8'
Write Node as XML to +io+ with +options+
##
def write_xml_to(io, options = {}) options[:save_with] ||= SaveOptions::DEFAULT_XML write_to io, options end
def xml?
def xml? type == DOCUMENT_NODE end