summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2016-12-01 21:41:45 +0100
committerSilvan Jegen <s.jegen@gmail.com>2016-12-01 21:41:45 +0100
commite75b77c73a89f3bcc1790ceb05fd1dc0051f15c2 (patch)
tree7368b3e4f23f0a82c0d7611be80e1adb44b3be00
parent58b49acd3a4bbaf99bbd96fcd7487adf52def1a4 (diff)
Get the text in sub-elements as well
-rwxr-xr-xpyeletree.py4
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")