Created
March 21, 2010 17:16
-
-
Save manveru/339434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'csv' | |
template = Nokogiri::XML(DATA.read) | |
builder = Nokogiri::XML::Builder.with(template.at('group')) do |group| | |
CSV.foreach('export', headers: true) do |row| | |
group.entry do |entry| | |
entry.title row['title'] | |
entry.username row['username'] | |
entry.password row['password'] | |
entry.url row['url'] | |
entry.comment row['notes'] | |
entry.icon 1 | |
entry.creation row['last_touch'] | |
entry.lastaccess row['last_touch'] | |
entry.lastmod row['last_touch'] | |
entry.expire 'Never' | |
end | |
end | |
end | |
puts builder.to_xml | |
__END__ | |
<!DOCTYPE KEEPASSX_DATABASE> | |
<database> | |
<group> | |
<title>Internet</title> | |
<icon>1</icon> | |
</group> | |
<group> | |
<title>eMail</title> | |
<icon>19</icon> | |
</group> | |
</database> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment