Hi,

the following works with NQXML.

How to write the equivalent for REXML?

------------------beware_of_added_line_breaks-------------------
require 'nqxml/treeparser'
require 'nqxml/writer'

main_doc = open('main_doc.xml') do |file|
   file.read
end
news_template = open('news_template.xml') do |file|
   file.read
end
content_repository = open('content_repository.xml') do |file|
   file.read
end

main_doc_tree           = NQXML::TreeParser.new(main_doc).document
news_template_tree      = NQXML::TreeParser.new(news_template).document
content_repository_tree = NQXML::TreeParser.new(content_repository).document

content_repository_to_include = content_repository_tree.rootNode.children[5]

news_template_to_include = 
news_template_tree.rootNode.firstChild.nextSibling.nextSibling.nextSibling


news_template_to_include.children << content_repository_to_include

main_doc_tree.rootNode.children << news_template_to_include


out = ''
writer = NQXML::Writer.new(out)
writer.writeDocument(main_doc_tree)

print out
-------------------------

Thanks,
Tobi

-- 
Tobias Reif
http://www.pinkjuice.com/myDigitalProfile.xhtml

go_to('www.ruby-lang.org').get(ruby).play.create.have_fun
http://www.pinkjuice.com/ruby/