Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44491
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <moraa.lovetakes2@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:not': 0.03; '21,': 0.07; 'attribute': 0.07; 'error:': 0.07; 'element,': 0.16; 'finds': 0.16; 'parameter.': 0.16; 'elements': 0.16; 'advance.': 0.19; '8bit%:5': 0.22; 'this?': 0.23; 'script': 0.25; 'pass': 0.26; 'skip:" 20': 0.27; 'values': 0.27; 'xml': 0.29; 'message- id:@mail.gmail.com': 0.30; 'saludos': 0.31; 'file': 0.32; 'skip:c 30': 0.32; '(most': 0.33; 'skip:& 30': 0.33; 'received:google.com': 0.35; 'thanks': 0.36; 'subject:?': 0.36; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'receive': 0.70; 'cater': 0.84; 'faith': 0.91; 'url:cn': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=o/Urru8JLjGjHg34Jsrw7BAMLflvkgsDMY7kemof2P4=; b=TZ4QWS51VL2UMXTEccsTgrObB1pJh/Excw+lMcEqE+nREHOhoLbS3nnNhgt5AAEwt1 WCADhCVGEnJhbK7P8t449a/K7iyFKMe9TAPYxIAt8nxvDPC1urzTNw9B/ssKtPQ11zWx jFqubsyq1uVU9Ef8KzGVVBFq4678IuXMj7GKeOPeTegg0b1T0sKeKty99O8AD082nCDs A/ctS7IGejDf86fdMFIiNI1IdCzwjcxZ9CclBibWhnEq9jwK8qnZVs8ZWqPJkOqoKfTO 2xL0YYYjKGWD+U3+GTO7tIRYXjW5hIYN7onq/W99AYBOYKcAs6Gm6jBzLqLGsTsmS59r waeA== |
| X-Received | by 10.60.131.98 with SMTP id ol2mr22995663oeb.37.1367231252033; Mon, 29 Apr 2013 03:27:32 -0700 (PDT) |
| MIME-Version | 1.0 |
| From | Ombongi Moraa Fe <moraa.lovetakes2@gmail.com> |
| Date | Mon, 29 Apr 2013 13:26:51 +0300 |
| Subject | RE: xml.etree.ElementTree if element does not exist? |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=089e01183b7a1a757604db7d55a0 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1147.1367231260.3114.python-list@python.org> (permalink) |
| Lines | 70 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1367231260 news.xs4all.nl 16002 [2001:888:2000:d::a6]:58457 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44491 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Good Afternoon,
Among other elements values that my script finds is value for sepid
sepid = content.find(".//{http://www.huawei.com.cn/schema/common/v2_1}sepid
").text
however, if i pass xml data that DOES NOT contain sepid element, i get an
error:
Traceback (most recent call last):
File "/usr/local/bin/receive.py", line 21, in <module>
sepid = content.find(".//{
http://www.huawei.com.cn/schema/common/v2_1}sepid").text
AttributeError: 'NoneType' object has no attribute 'text'
some messages i receive will have the sepid parameter, other will not have
this parameter. How can i cater for this? kinda like an if .. else
implementation for xml.etree.ElementTree ?
Thanks in advance.
Saludos
Ombongi Moraa Faith
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
RE: xml.etree.ElementTree if element does not exist? Ombongi Moraa Fe <moraa.lovetakes2@gmail.com> - 2013-04-29 13:26 +0300
Re: xml.etree.ElementTree if element does not exist? Neil Cerutti <neilc@norwich.edu> - 2013-04-29 12:25 +0000
Re: xml.etree.ElementTree if element does not exist? Neil Cerutti <neilc@norwich.edu> - 2013-04-29 12:29 +0000
csiph-web