-
-
Save Alfaj0r/1713679 to your computer and use it in GitHub Desktop.
Powerscribe templates XML parsing
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/env ruby | |
require 'rexml/document' | |
include REXML | |
#open the XML file exported from Powerscribe | |
# Ruby lets us open the file in a block (thereby closing it when it's done) | |
File.open("Voice.xml") do |file| | |
# The "block" is that do ... end syntax and |file| is a reference to the file we've opened | |
doc = Document.new(file) | |
root = doc.root | |
#for each element of listed in the XML file we want to: | |
# display the "shortText" (which is the title of the Template) | |
# display the "longText" (which is the actual text of the Template) | |
root.elements.each("item") do |item| | |
# Just output the field of the item which is available as a node in the XML | |
puts "Template title:" | |
puts item.elements['shortText'].get_text | |
puts "Template text:" | |
puts item.elements['longText'].get_text | |
puts "***********************************" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment