class Nokogiri::XML::Node
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.is_a?(XML::Document) && !node_or_tags.is_a?(XML::ProcessingInstruction) node_or_tags = coerce(node_or_tags) if node_or_tags.is_a?(XML::NodeSet) if text? pivot = Nokogiri::XML::Node.new 'dummy', document add_previous_sibling_node pivot else pivot = self end node_or_tags.each { |n| pivot.send :add_previous_sibling_node, n } pivot.unlink if text? else add_previous_sibling_node node_or_tags end node_or_tags end