diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2016-12-01 21:41:45 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2016-12-01 21:41:45 +0100 |
commit | e75b77c73a89f3bcc1790ceb05fd1dc0051f15c2 (patch) | |
tree | 7368b3e4f23f0a82c0d7611be80e1adb44b3be00 | |
parent | 58b49acd3a4bbaf99bbd96fcd7487adf52def1a4 (diff) |
Get the text in sub-elements as well
-rwxr-xr-x | pyeletree.py | 4 |
1 files 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") |