Skip to content

Instantly share code, notes, and snippets.

@scips
Last active November 27, 2017 14:56
Show Gist options
  • Save scips/b45a4506450169398744632f758741f3 to your computer and use it in GitHub Desktop.
Save scips/b45a4506450169398744632f758741f3 to your computer and use it in GitHub Desktop.
Parse Json or Xml with python and return a signle value

Parse XML file and return a node text value

elementValue=`cat somefile.xml | python -c 'import sys, xml.etree.cElementTree as et;\
 tree = et.parse(sys.stdin); print tree.find("elementValue").text'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment