diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2016-09-13 21:33:15 +0200 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2016-09-13 21:33:15 +0200 |
commit | 7cac2d95f2f9b96405a280d21974e7ca723c17b4 (patch) | |
tree | 4452f1abbb19736432cc1f5fba1f8719b09fbd8f | |
parent | 47289e62f0e29f969df85379644c99bfde1385a0 (diff) |
Add pyeletree.py
-rwxr-xr-x | pyeletree.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pyeletree.py b/pyeletree.py new file mode 100755 index 0000000..4b30159 --- /dev/null +++ b/pyeletree.py @@ -0,0 +1,16 @@ +#! /usr/bin/python2 + +import sys +import xml.etree.ElementTree as et + +def process(f): + r = et.parse(f).getroot() + tg = r.findall("./front/article-meta/title-group") + at = tg[0].find("article-title") + if at is not None and at.text is not None: + print "article-title:", at.text.encode('utf-8') + +for xmlf in sys.argv[1:]: + f = open(xmlf, "rb") + process(f) + f.close() |