Skip to content

Instantly share code, notes, and snippets.

@dforest
Created November 4, 2014 08:26
Show Gist options
  • Save dforest/61cdcd81fb65e58bba23 to your computer and use it in GitHub Desktop.
Save dforest/61cdcd81fb65e58bba23 to your computer and use it in GitHub Desktop.
Generate csv from strings.xml of android
require 'csv'
require 'nokogiri'
##
# First, you must wrap nodes by <sample> you want to generate csv
##
SAMPLE_TAG_NAME = "sample"
csv = CSV.open('strings.csv', 'w')
Nokogiri::XML(open(ARGV[0])).xpath("//#{SAMPLE_TAG_NAME}//string").each do |string|
csv << [string.attribute('name'), string.text]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment