本文整理汇总了Python中comoonics.XmlTools.getTextFromElement方法的典型用法代码示例。如果您正苦于以下问题:Python XmlTools.getTextFromElement方法的具体用法?Python XmlTools.getTextFromElement怎么用?Python XmlTools.getTextFromElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comoonics.XmlTools
的用法示例。
在下文中一共展示了XmlTools.getTextFromElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromXML
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import getTextFromElement [as 别名]
def fromXML(element, theclass=None):
from xml.dom import Node
from comoonics import XmlTools
localmap=globals()
objecttype=None
instance=None
if not theclass:
ot_elements=element.getElementsByTagName("objecttype")
if len(ot_elements)==1:
objecttype=XmlTools.getTextFromElement(ot_elements[0])
#mylogger.debug("objecttype: %s, %s" %(objecttype, localmap))
if localmap.has_key("HP_EVA_%s" %(element.nodeName.capitalize())) and not theclass and not objecttype:
myclass=localmap["HP_EVA_%s" %(element.nodeName.capitalize())]
#mylogger.debug("theclass: %s" %(myclass))
instance=HP_EVA_Object.fromXML(element, myclass)
elif objecttype and localmap.has_key("HP_EVA_%s" %(objecttype.capitalize())) and not theclass:
myclass=localmap["HP_EVA_%s" %(objecttype.capitalize())]
#mylogger.debug("theclass: %s" %(myclass))
instance=HP_EVA_Object.fromXML(element, myclass)
elif theclass:
#mylogger.debug("theclass: %s" %(theclass))
instance=object.__new__(theclass)
instance.__init__()
for child in element.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
paramname=child.nodeName
paramvalue=XmlTools.getTextFromElement(child)
if paramvalue:
paramvalue=paramvalue.strip()
if paramname and paramvalue and paramvalue!="":
#mylogger.debug("setattr(%s, %s, %s)" %(theclass, paramname, paramvalue))
setattr(instance, paramname, paramvalue)
elif paramname == "parentstoragecellinfo":
ids=child.getElementsByTagName("storagecellid")
if len(ids)==1:
id=XmlTools.getTextFromElement(ids[0])
if HP_EVA_Storagecells.has_key(id):
#mylogger.debug("storagecellkey: %s, keys: %s, has_key:%u" %(id, HP_EVA_Storagecells.names(), HP_EVA_Storagecells.has_key(id)))
instance.setParent(HP_EVA_Storagecells.get(id))
elif paramname:
setattr(instance, paramname, HP_EVA_Object.fromXML(child))
return instance
示例2: _do
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import getTextFromElement [as 别名]
def _do(self):
_message=""
if self.parent.hasAttribute("message"):
_message=self.parent.getAttribute("message")
_message+="\n"
else:
_textelements=self.parent.getElement().getElementsByTagName("text")
for _textelement in _textelements:
_message+=XmlTools.getTextFromElement(_textelement)
_message+="\n"
self.out.write(_message)
###################
# $Log: ComMessage.py,v $
# Revision 1.2 2010-03-08 12:30:48 marc
# version for comoonics4.6-rc1
#
# Revision 1.1 2007/09/07 14:37:56 marc
# initial revision
#
示例3: testGetTextFromElement
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import getTextFromElement [as 别名]
def testGetTextFromElement(self):
doc=self.docs[3][0]
self.assertEquals(None, XmlTools.getTextFromElement(doc.documentElement))
示例4: testGetTextFromElement1
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import getTextFromElement [as 别名]
def testGetTextFromElement1(self):
doc=self.docs[2][0]
self.assertEquals("abcd", XmlTools.getTextFromElement(doc.documentElement))
示例5: _parse_dateformat
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import getTextFromElement [as 别名]
def _parse_dateformat(self, cursect, child):
_format=XmlTools.getTextFromElement(child)
cursect["dateformat"]=_format