Advertisement
Guest User

Untitled

a guest
May 13th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #Daniel Blaney
  2.  
  3. require 'rubygems'
  4. require 'zip/zip'
  5. require 'nokogiri'
  6.  
  7. v1 = ARGV[0]
  8. v2 = v1.sub(/docx/, 'txt')
  9.  
  10. zip = Zip::ZipFile.open(v1)
  11. doc = zip.find_entry("word/document.xml")
  12.  
  13. xml = Nokogiri::XML.parse(doc.get_input_stream)
  14. wt = xml.root.xpath("//w:t", {"w" => "http://schemas.openxmlformats.org/wordprocessingml/2006/main"}).text
  15.  
  16. f = File.new(v2, "w")
  17.  
  18. f.write(wt)
  19.  
  20. puts v2
  21. puts wt
  22. f.close
  23. zip.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement