变量问题
greex 2013-05-19 03:20:05 def __init__(self,parentNode,node):
self.__node=node
self.__allChildNodes=[]
tmpTextValue=''
print 000
for item in self.__node.childNodes:
if(item.nodeType==1):
tmpNodeInfo=nodeInfo(self.__node,item)
setattr(tmpNodeInfo,tmpNodeInfo.tagName(),tmpNodeInfo.allChildNodes())
for itemKey in item.attributes.keys():
setattr(tmpNodeInfo,itemKey,item.getAttribute(itemKey))
print 222,tmpTextValue
if(len(tmpTextValue) > 0):
setattr(tmpNodeInfo,'textValue',tmpTextValue)
self.__allChildNodes.append(tmpNodeInfo)
elif item.nodeType==3 and len(item.nodeValue.strip())>0:
tmpTextValue=item.nodeValue.strip()
print 333,tmpTextValue
这是部分打印信息:
0
333 MSXML 5.0 SDK
222
222
tmpTextValue是先赋值的,怎么后面访问是又为空呢?