Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Daniel Blaney
- require 'rubygems'
- require 'zip/zip'
- require 'nokogiri'
- v1 = ARGV[0]
- v2 = v1.sub(/docx/, 'txt')
- zip = Zip::ZipFile.open(v1)
- doc = zip.find_entry("word/document.xml")
- xml = Nokogiri::XML.parse(doc.get_input_stream)
- wt = xml.root.xpath("//w:t", {"w" => "http://schemas.openxmlformats.org/wordprocessingml/2006/main"}).text
- f = File.new(v2, "w")
- f.write(wt)
- puts v2
- puts wt
- f.close
- zip.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement