Last active
August 8, 2018 20:34
-
-
Save privatezero/095efe7ea47cce9b1ea1f3a4e94328ed 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' | |
filename = '' | |
doc = Nokogiri.XML(File.open(filename)) | |
ead = doc.at_css "ead" | |
# Clear EAD attributes | |
ead.each { |att_name| }.each do |attribute_name| | |
ead.delete(attribute_name) | |
end | |
# Add new EAD attributes | |
ead['xsi:schemaLocation'] = "urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd" | |
ead['xmlns'] = "urn:isbn:1-931666-22-9" | |
ead['xmlns:ns2'] = "http://www.w3.org/1999/xlink" | |
ead['xmlns:xsi'] = "http://www.w3.org/2001/XMLSchema-instance" | |
doc.internal_subset.remove | |
File.write(filename,doc.to_xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment