2012. 1. 16.

extract list from XML (xmldom) in python


data ="
 aaa
 bbb
 ccc
 ddd
 eee
"


from xml.dom.minidom import parse, parseString

#data is xml formatted string 

dom3 = parseString( data )   #make dom object
tagList = dom3.getElementsByTagName("tag1")  #select list "tag1"

txt = tagList[0].firstChild.nodeValue  #first node->txtNode->nodeValue
print txt

===result==========
aaa

댓글 없음:

댓글 쓰기