Skip to content

Instantly share code, notes, and snippets.

@vulpine
Created April 18, 2017 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vulpine/93425a04035569351951de8513ec8432 to your computer and use it in GitHub Desktop.
Save vulpine/93425a04035569351951de8513ec8432 to your computer and use it in GitHub Desktop.
The very early beginnings of a D&D Character Builder Parser in Ruby.
#!/usr/bin/ruby
require 'nokogiri'
def get_file_xml(filename)
xml = File.open(filename, 'rb') { |f| Nokogiri::XML(f) }
xml
end
def get_race_names(xml)
xml.xpath('//RulesElement').each do |ruleselement|
if ruleselement.attr('type') == "Race"
puts ruleselement.attr('name')
end
end
end
# Fix this eventually, but for now just grab the first argument.
filename = ARGV[0]
xml = get_file_xml(filename)
get_race_names(xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment