我正在使用 ksoap 在 android 应用程序和包含发布以下文件的 python 服务器之间进行通信。我正在尝试检索发布的 XML 文件中的所有值。但我不断得到,AttributeError: 'NoneType' object has no attribute 'nodeValue'
。任何人都可以告诉我代码有什么问题,因为我试图调试错误但仍然没有这样做。
XML 文件的一部分(只有 MacFilterList 和 Map 节点可以为空):
<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