鉴于这一xml文档,我谨从中提取数据。 然而,在<代码>和“LandmarkPointListXml>”上提取数据有困难;。
<>XML文档:
<?xml version="1.0" encoding="utf-8"?>
<Map xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MapName>er</MapName>
<MapURL>er.gif</MapURL>
<Name>er</Name>
<URL>er.gif</URL>
<LandmarkPointListXml>
<anyType xsi:type="LandmarkPointProperty">
<LandmarkPointX>400</LandmarkPointX>
<LandmarkPointY>292</LandmarkPointY>
<LandmarkDesc>my room door</LandmarkDesc>
</anyType>
<anyType xsi:type="LandmarkPointProperty">
<LandmarkPointX>399</LandmarkPointX>
<LandmarkPointY>219</LandmarkPointY>
<LandmarkDesc>bro room door</LandmarkDesc>
</anyType>
</LandmarkPointListXml>
<RegionPointListXml />
</Map>
www.un.org/Depts/DGACM/index_spanish.htm 粉碎计划:
def GetMapData(self):
result = ""
haha = self.XMLdoc.firstChild #root node
for child in haha.childNodes:
if (cmp(child.nodeName, LandmarkPointListXml )==0):
result = result + | + self.loopLandmark(child.childNodes) + |
else:
result = result + child.firstChild.nodeValue + ,
return result
def loopLandmark(self, landmarks):
result=""
haha=landmarks.getElementsByTagName( anyType )
for child in haha.childNodes:
if (cmp(haha.firstChild.nodeName, LandmarkPointX ) == 0):
result=result+child.firstChild.nodeValue+ ,
ChildNode = ChildNode.nextSibling
result=result+child.firstChild.nodeValue+ ,
ChildNode = ChildNode.nextSibling
result=result+child.firstChild.nodeValue
return result
我得以检索结果,即“er,er.gif,er,er.gif”,直到方案达到<LandmarkPointListXml>
。