From e75b77c73a89f3bcc1790ceb05fd1dc0051f15c2 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Thu, 1 Dec 2016 21:41:45 +0100 Subject: Get the text in sub-elements as well --- pyeletree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyeletree.py b/pyeletree.py index 4b30159..0af240f 100755 --- a/pyeletree.py +++ b/pyeletree.py @@ -7,8 +7,8 @@ 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') + if at is not None: + print "article-title:", "".join(at.itertext()).encode('utf-8') for xmlf in sys.argv[1:]: f = open(xmlf, "rb") -- cgit v1.2.1-18-gbd029