Skip to content

Instantly share code, notes, and snippets.

@davidcsi
Created December 19, 2017 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcsi/4695aa9a18ff4f05857d10b4823763f9 to your computer and use it in GitHub Desktop.
Save davidcsi/4695aa9a18ff4f05857d10b4823763f9 to your computer and use it in GitHub Desktop.
ruby, print when the current element is the last one.
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