KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a node which has two children: an HTML text and an HTML element. <h1 id="Installation-blahblah">Installation on server<a href="#Installation-blah" class="wiki-anchor">¶</a> </h1> In this case the HTML text is: Installation on server and the HTML element: <a href="#Installation-blah" class="wiki-anchor">anchor;</a> I then create a node like this: span_node = Nokogiri::HTML::Node.new('span',doc) span_node['class'] = 'edit-section' link_node = Nokogiri::HTML::Node.new('a',doc) link_node['href'] = "/wiki/#{page_id}/#{@page.title}/edit?section=#{section_index}" link_node['class'] = 'icon icon-edit' link_node.content = 'mylink' span_node.add_child(link_node) Now, to add the above node to the main node I use the following: node.add_child(span_node) This appends the span node at the end. How can I put the span_node in front of all children?
Tags (comma-separated)
Save Edits
Cancel