Index: ext/xml/ruby_xml_node.c
===================================================================
RCS file: /var/cvs/libxml/libxml/ext/xml/ruby_xml_node.c,v
retrieving revision 1.3
diff -u -r1.3 ruby_xml_node.c
--- ext/xml/ruby_xml_node.c	12 Apr 2006 12:08:39 -0000	1.3
+++ ext/xml/ruby_xml_node.c	7 May 2006 18:01:00 -0000
@@ -1333,6 +1333,32 @@
 
 /*
  * call-seq:
+ *    node.next = node
+ * 
+ * Insert the specified node as this node's next sibling.
+ */
+VALUE
+ruby_xml_node_next_set(VALUE self, VALUE rnode) {
+  ruby_xml_node *cnode, *pnode;
+  xmlNodePtr ret;
+
+  if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
+    rb_raise(rb_eTypeError, "Must pass an XML::Node object");
+
+  Data_Get_Struct(self,  ruby_xml_node, pnode);
+  Data_Get_Struct(rnode, ruby_xml_node, cnode);
+
+  ret = xmlAddNextSibling(pnode->node, cnode->node);
+  if (ret == NULL)
+    rb_raise(eXMLNodeFailedModify, "unable to add a sibling to the document");
+
+  cnode->is_ptr = 1;
+  return(ruby_xml_node_new2(cXMLNode, pnode->xd, ret));
+}
+
+
+/*
+ * call-seq:
  *    node.notation? => (true|false)
  * 
  * Determine whether this is a notation node
@@ -1619,6 +1645,32 @@
 
 /*
  * call-seq:
+ *    node.prev = node
+ * 
+ * Insert the specified node as this node's previous sibling.
+ */
+VALUE
+ruby_xml_node_prev_set(VALUE self, VALUE rnode) {
+  ruby_xml_node *cnode, *pnode;
+  xmlNodePtr ret;
+
+  if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
+    rb_raise(rb_eTypeError, "Must pass an XML::Node object");
+
+  Data_Get_Struct(self,  ruby_xml_node, pnode);
+  Data_Get_Struct(rnode, ruby_xml_node, cnode);
+
+  ret = xmlAddPrevSibling(pnode->node, cnode->node);
+  if (ret == NULL)
+    rb_raise(eXMLNodeFailedModify, "unable to add a sibling to the document");
+
+  cnode->is_ptr = 1;
+  return(ruby_xml_node_new2(cXMLNode, pnode->xd, ret));
+}
+
+
+/*
+ * call-seq:
  *    node.property("name") => "string"
  *    node["name"]          => "string"
  * 
@@ -2104,6 +2156,7 @@
   rb_define_method(cXMLNode, "namespace=", ruby_xml_node_namespace_set, -1);  
   rb_define_method(cXMLNode, "next", ruby_xml_node_next_get, 0);
   rb_define_method(cXMLNode, "next?", ruby_xml_node_next_q, 0);
+  rb_define_method(cXMLNode, "next=", ruby_xml_node_next_set, 1);
   rb_define_method(cXMLNode, "node_type", ruby_xml_node_type, 0);
   rb_define_method(cXMLNode, "node_type_name", ruby_xml_node_type_name, 0);
   rb_define_method(cXMLNode, "notation?", ruby_xml_node_notation_q, 0);
@@ -2118,6 +2171,7 @@
   rb_define_method(cXMLNode, "pointer", ruby_xml_node_pointer, 1);
   rb_define_method(cXMLNode, "prev", ruby_xml_node_prev_get, 0);
   rb_define_method(cXMLNode, "prev?", ruby_xml_node_prev_q, 0);
+  rb_define_method(cXMLNode, "prev=", ruby_xml_node_prev_set, 1);
   rb_define_method(cXMLNode, "property", ruby_xml_node_property_get, 1);
   rb_define_method(cXMLNode, "properties", ruby_xml_node_properties_get, 0);
   rb_define_method(cXMLNode, "properties?", ruby_xml_node_properties_q, 0);
Index: tests/tc_xml_node5.rb
===================================================================
RCS file: tests/tc_xml_node5.rb
diff -N tests/tc_xml_node5.rb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/tc_xml_node5.rb	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,53 @@
+# $Id: tc_xml_node.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
+require "libxml_test"
+require 'test/unit'
+
+class TC_XML_Node < Test::Unit::TestCase
+  def setup()
+    xp = XML::Parser.new()
+    str = '<test><num>one</num><num>two</num><num>three</num></test>'
+    assert_equal(str, xp.string = str)
+    @doc = xp.parse
+    assert_instance_of(XML::Document, @doc)
+    @root = @doc.root
+    @num1 = @root.child
+    @num2 = @num1.next
+    @num3 = @num2.next
+  end
+  
+  def test_libxml_node_add_next_01
+    @num1.next = XML::Node.new('num', 'one-and-a-half')
+    assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
+      @root.to_s.gsub(/\n\s*/,'')
+  end
+  
+  def test_libxml_node_add_next_02
+    @num2.next = XML::Node.new('num', 'two-and-a-half')
+    assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
+      @root.to_s.gsub(/\n\s*/,'')
+  end
+  
+  def test_libxml_node_add_next_03
+    @num3.next = XML::Node.new('num', 'four')
+    assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
+      @root.to_s.gsub(/\n\s*/,'')
+  end
+  
+  def test_libxml_node_add_prev_01
+    @num1.prev = XML::Node.new('num', 'half')
+    assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
+      @root.to_s.gsub(/\n\s*/,'')
+  end
+  
+  def test_libxml_node_add_prev_02
+    @num2.prev = XML::Node.new('num', 'one-and-a-half')
+    assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
+      @root.to_s.gsub(/\n\s*/,'')
+  end
+  
+  def test_libxml_node_add_prev_03
+    @num3.prev = XML::Node.new('num', 'two-and-a-half')
+    assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
+      @root.to_s.gsub(/\n\s*/,'')
+  end  
+end
