Created
August 26, 2016 18:50
-
-
Save tinhajj/95a2d97acd35d610cec4eb61845af4b0 to your computer and use it in GitHub Desktop.
nokogiri/diff issue
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
<root> | |
<leaf1> | |
<subleaf id="test"></subleaf> | |
</leaf1> | |
<leaf2> | |
<subleaf got="game">text</subleaf> | |
<subleaf id="hello">inside</subleaf> | |
</leaf2> | |
</root> |
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
<root> | |
<leaf2> | |
<subleaf id="hello">inside</subleaf> | |
<subleaf got="game">text</subleaf> | |
</leaf2> | |
<leaf1> | |
<subleaf id="test"></subleaf> | |
</leaf1> | |
</root> |
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' | |
require 'nokogiri/diff' | |
xml_doc1 = File.open("first.xml") { |f| Nokogiri::XML(f) } | |
xml_doc2 = File.open("second.xml") { |f| Nokogiri::XML(f) } | |
xml_doc1.diff(xml_doc2, { added: 'true' }) do |change, node| | |
p "#{change} #{node}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment