çoğu durumda kullanacağımız yalnızca ilk erişilen node'un metinini

çekmek için bir fonksiyon eklendi.
This commit is contained in:
Barış Metin
2005-06-09 09:36:41 +00:00
parent 8dd88de922
commit aa3ab32680
+19 -2
View File
@@ -24,8 +24,25 @@ from a PSPEC file"""
return nodelist
def getText(self, nodepath):
pass
def getFirstNode(self, nodepath):
try:
return self.getNodes(nodepath)[0]
except IndexError:
return None
def getFirstChildText(self, nodepath):
node = self.getFirstNode(nodepath)
if not node:
return None
# get the first child
try:
child = node.childNodes[0]
except IndexError:
return None
if child.nodeType == child.TEXT_NODE:
return child.data
def getAttribute(self, nodepath, attribute):
pass