Created
April 18, 2017 22:24
-
-
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.
This file contains 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
#!/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