Skip to content

Instantly share code, notes, and snippets.

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(, doc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment