Skip to content

Instantly share code, notes, and snippets.

@Alfaj0r
Created January 31, 2012 22:39
Show Gist options
  • Save Alfaj0r/1713518 to your computer and use it in GitHub Desktop.
Save Alfaj0r/1713518 to your computer and use it in GitHub Desktop.
Powerscribe templates XML parsing
#!/usr/bin/env ruby
require 'rexml/document'
include REXML
#open the XML file exported from Powerscribe
file = File.new("Voice.xml")
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)
#this works for spitting out element 3 for example:
puts "Template: " + root.elements[3].elements["shortText"].get_text.to_s
puts "Template text:" + root.elements[3].elements["longText"].get_text.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment