Created
December 19, 2017 23:08
-
-
Save davidcsi/4695aa9a18ff4f05857d10b4823763f9 to your computer and use it in GitHub Desktop.
ruby, print when the current element is the last one.
This file contains hidden or 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
puts doc.xpath('//*[not(*)][text()]').map{ | |
|n| | |
if is_number?(n.text) | |
"'#{n.parent.name}.#{n.name}': #{n.text}" | |
else | |
"'#{n.parent.name}.#{n.name}': '#{n.text}'" | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment