Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Neil Cerutti
On 2013-04-29, Neil Cerutti wrote: > find returns None when it doesn't find what you asked for. So you > can't check the .text attribute right away unless you want an > exception thrown. I deal with these annoyances like this: > > sepelem = > content.find(".//{http://www.huawei.com.cn/schema/comm

Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Neil Cerutti
On 2013-04-29, Ombongi Moraa Fe wrote: > > 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

Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Ombongi Moraa Fe
Hi Stefan, Group Thanks for the thumbs up. Worked perfectly. Saludos Ombongi Moraa Faith On 29 April 2013 14:22, Stefan Holdermans wrote: > Ombongi, > > > however, if i pass xml data that DOES NOT contain sepid element, i get > an error: > > > > Traceback (most recent call last): > > File

Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Stefan Holdermans
Ombongi, > 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 > sepid = > content.find(".//{http://www.huawei.com.cn/schema/common/v2_1}sepid";).text > AttributeError: '

RE: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Ombongi Moraa Fe
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 "/u