Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View xml_name_finder.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
require 'builder'
 
if ARGV.size == 0
puts "usage: #{File.basename(__FILE__)} <input>.xml ..."
puts "output: <input>.result.xml ..."
exit
end
 
ARGV.each do |file|
File.open(file.sub(/\.xml/,'.result.xml'), 'w') do |out|
xml = Builder::XmlMarkup.new(:target => out, :indent => 2)
xml.instruct!
xml.people do |people|
first_name = nil
IO.foreach(file) do |line|
if md = line.match(/<(.*)>(.*)<\/\1>/)
case md[1]
when /first/
first_name = md[2]
when /last|sur/
people.person do |person|
person.name do |name|
name.first first_name
name.last md[2]
end
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.