Created
July 25, 2009 00:16
-
-
Save paytonrules/154628 to your computer and use it in GitHub Desktop.
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
require 'nokogiri' | |
system 'unzip Alliance.docx' | |
doc = Nokogiri::XML(open('word/document.xml')) | |
# Using Label Tag | |
doc.xpath("//w:fldSimple[contains(@w:instr, 'label_tag')]").each do |link| | |
command = link.attributes["instr"].value.match(/\#\{(.*)\}/)[1] | |
replacement_string = eval(command) | |
element.replace(Nokogiri::XML::Text.new(replacement_string, doc)) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment