Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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