Created
July 13, 2016 23:31
-
-
Save garrettgsb/9911f98ba2639e13ce692eb3944b2d86 to your computer and use it in GitHub Desktop.
Removes values from XML, leaving just the tree.
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
# Parses XML file with Nokogiri, | |
# removes text from all nodes, | |
# prints out new 'clean' file | |
# Change 'input.xml' to whatever | |
# file you want to scrub. | |
require 'nokogiri' | |
doc = File.open('input.xml') {|f| Nokogiri::XML(f)} | |
doc.traverse{|node| node.content = "" if node.class == Nokogiri::XML::Text} | |
File.write('output.xml', doc.to_xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment