ksoap을 사용하여 Android 앱과 다음 파일이 포함 된 Python 서버간에 통신합니다. 게시 된 XML 파일의 모든 값을 검색하려고합니다. 하지만 계속, AttributeError: 'NoneType' object has no attribute 'nodeValue'
. 누구든지 오류를 디버깅하려했지만 여전히 그렇게하지 못했을 때 코드의 문제점을 알 수 있습니까? XML 파일의AttributeError : 'NoneType'객체에 'nodeValue'속성이 없습니다.
부분 (만 MacFilterList 및지도 노드 비어있을 수 있습니다) :
<ProfileList>
<Profile>
<ProfileName>Lab1</ProfileName>
<Owner>admin</Owner>
<Map>Lab</Map>
<Visible>True</Visible>
<MacFilterList>
<string>00:14:BF:9F:5D:3A</string>
<string>00:14:BF:9F:5D:52</string>
<string>00:14:BF:9F:5D:37</string>
<string>00:14:BF:9F:5D:43</string>
</MacFilterList>
</Profile>
.
.
</ProfileList>
soapAPI.py은 (PROFILE_XML
xml 파일의 파일 이름을 의미합니다.) :
def __init__(self):
self.profileFile = Config.PROFILE_XML
self.profile = XML_ProfileDataStore()
self.profile.LoadXMLFile(self.profileFile)
.
.
def GetAllProfileData(self):
self.profileFile = Config.PROFILE_XML
self.profile.LoadXMLFile(self.profileFile)
result = self.profile.GetAllProfileData()
return result
profileData.py (클래스가 XML_ProfileDataStore
인 경우) :
def GetAllProfileData(self):
#Get a node list containing nodes with name Location
ProfileList = self.XMLdoc.getElementsByTagName('Profile')
NumArgCheck = 0
profiles=""
#For each location node in list
for profileNode in ProfileList:
#For each child nodes in Location node, compare the XY coordinates
for ChildNode in profileNode.childNodes:
#If child node has profile name profile_name
if (cmp(ChildNode.nodeName, 'ProfileName') == 0):
NumArgCheck += 1
profiles = profiles + ChildNode.firstChild.data + ","
ChildNode = ChildNode.nextSibling
profiles = profiles + ChildNode.firstChild.nodeValue + ","
ChildNode = ChildNode.nextSibling
profiles = profiles + ChildNode.firstChild.nodeValue + ","
ChildNode = ChildNode.nextSibling
profiles = profiles + ChildNode.firstChild.nodeValue
ChildNode = ChildNode.nextSibling
for child in ChildNode.childNodes:
profiles = profiles + "," + child.firstChild.nodeValue
profiles = profiles+";"
return profiles
XML 파일의 요소 중 일부를 가져 오기 섹션에서
, 그리고 빈 요소이다. 그러나 이러한 경우를 확인하기 위해 코딩을 구현 한 후에도 오류는 여전히 남아 있습니다. 또한 서버에서 .py 파일을 만들어 안드로이드 클라이언트 응용 프로그램 대신 데이터를 검색하는 대신 응용 프로그램이 아닌 안드로이드 클라이언트 응용 프로그램을 사용했습니다. –
user918197