Class: Xml

Inherits:
Thor
  • Object
show all
Defined in:
lib/mediawiki_cli/xml.rb

Instance Method Summary collapse

Instance Method Details

#merge(*xml) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mediawiki_cli/xml.rb', line 8

def merge(*xml)

	mwns = "http://www.mediawiki.org/xml/export-0.5/"

	first = xml.shift
	f = File.open(first) if File.exists? first
	master = Nokogiri::XML f

	others = xml.each { |x|
		x = File.open(x) if File.exists? x
		doc = Nokogiri::XML x
		doc.xpath("//mediawiki:page", "mediawiki"=>mwns).each {|n|
			master.root.add_child n	
		}
	}

	puts master.root.to_xml
end