<?xml version='1.0' encoding='utf-8'?>
<rss version="2.0">
<channel>
<title>
Naver Open API - endic ::'media'
</title>
<link>
http://search.naver.com
</link>
<description>
Naver Search Result
</description>
<lastbuilddate>
Fri, 31 Jul 2009 11:17:34 +0900
</lastbuilddate>
<total>
24
</total>
<start>
1
</start>
<display>
5
</display>
<item>
<title>
media<SUP>1</SUP>
</title>
<link>
http://openapi.naver.com/l?AAACupLEi1Tc1LyUxWK81MsTUxMzK1UCssTS2qtM1NTclMVMsoSk2zzSgpKVA1dlQ1cgMisGq9vMSy1CK95PxcVBFVY7eU/OTMFFVjF3MDcwtjAwBNvkKqYQAAAA==
</link>
</item>
<item>
<title>
media<SUP>2</SUP>
</title>
<link>
http://openapi.naver.com/l?AAACupLEi1Tc1LyUxWK81MsTUxMzK1UCssTS2qtM1NTclMVMsoSk2zzSgpKVA1dlQ1cgMisGq9vMSy1CK95PxcVBFVY7eU/OTMFFVjF3MDcwsTAwCKKAPlYQAAAA==
</link>
</item>
</channel>
</rss></rss>
<?xml version="1.0" encoding="UTF-8"?>
<error xmlns="naver:openapi"> 전송된 요청을 수행하는 동안 다음과 같은 에러가 발생하였습니다.
<error_code>020</error_code>
<message>Unregistered key (등록되지 않은 키입니다.)</message>
</error>
ElementTree
import xml.etree.ElementTree as ET
...
ndicResult = ET.XML(xml_source_string)
#find error
if ndicResult.tag == '{naver:openapi}error':
print ndicResult.text
print "%s: %s"%(ndicResult.find('{naver:openapi}error_code').text, ndicResult.find('{naver:openapi}message').text)
elif ndicResult.tag == 'rss':
#find channel
ndicChann = ndicResult[0] #ndicResult.find('channel')
ndicItems = (i for i in ndicChann if i.tag=="item")
ndicLinks = map(lambda x: x.find('link').text, ndicItems)