當前位置: 首頁>>代碼示例>>Python>>正文


Python Node.CDATA_SECTION_NODE屬性代碼示例

本文整理匯總了Python中xml.dom.Node.CDATA_SECTION_NODE屬性的典型用法代碼示例。如果您正苦於以下問題:Python Node.CDATA_SECTION_NODE屬性的具體用法?Python Node.CDATA_SECTION_NODE怎麽用?Python Node.CDATA_SECTION_NODE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在xml.dom.Node的用法示例。


在下文中一共展示了Node.CDATA_SECTION_NODE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: character_data_handler_cdata

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import CDATA_SECTION_NODE [as 別名]
def character_data_handler_cdata(self, data):
        childNodes = self.curNode.childNodes
        if self._cdata:
            if (  self._cdata_continue
                  and childNodes[-1].nodeType == CDATA_SECTION_NODE):
                childNodes[-1].appendData(data)
                return
            node = self.document.createCDATASection(data)
            self._cdata_continue = True
        elif childNodes and childNodes[-1].nodeType == TEXT_NODE:
            node = childNodes[-1]
            value = node.data + data
            node.data = value
            return
        else:
            node = minidom.Text()
            node.data = data
            node.ownerDocument = self.document
        _append_child(self.curNode, node) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:21,代碼來源:expatbuilder.py

示例2: character_data_handler_cdata

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import CDATA_SECTION_NODE [as 別名]
def character_data_handler_cdata(self, data):
        childNodes = self.curNode.childNodes
        if self._cdata:
            if (  self._cdata_continue
                  and childNodes[-1].nodeType == CDATA_SECTION_NODE):
                childNodes[-1].appendData(data)
                return
            node = self.document.createCDATASection(data)
            self._cdata_continue = True
        elif childNodes and childNodes[-1].nodeType == TEXT_NODE:
            node = childNodes[-1]
            value = node.data + data
            d = node.__dict__
            d['data'] = d['nodeValue'] = value
            return
        else:
            node = minidom.Text()
            d = node.__dict__
            d['data'] = d['nodeValue'] = data
            d['ownerDocument'] = self.document
        _append_child(self.curNode, node) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:expatbuilder.py

示例3: getNodeDetails

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import CDATA_SECTION_NODE [as 別名]
def getNodeDetails(self, node):
        if node.nodeType == Node.DOCUMENT_TYPE_NODE:
            return _base.DOCTYPE, node.name, node.publicId, node.systemId

        elif node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
            return _base.TEXT, node.nodeValue

        elif node.nodeType == Node.ELEMENT_NODE:
            attrs = {}
            for attr in node.attributes.keys():
                attr = node.getAttributeNode(attr)
                attrs[(attr.namespaceURI,attr.localName)] = attr.value
            return (_base.ELEMENT, node.namespaceURI, node.nodeName, 
                    attrs, node.hasChildNodes())

        elif node.nodeType == Node.COMMENT_NODE:
            return _base.COMMENT, node.nodeValue

        elif node.nodeType in (Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE):
            return (_base.DOCUMENT,)

        else:
            return _base.UNKNOWN, node.nodeType 
開發者ID:caronc,項目名稱:nzb-subliminal,代碼行數:25,代碼來源:dom.py

示例4: getNodeDetails

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import CDATA_SECTION_NODE [as 別名]
def getNodeDetails(self, node):
        if node.nodeType == Node.DOCUMENT_TYPE_NODE:
            return base.DOCTYPE, node.name, node.publicId, node.systemId

        elif node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
            return base.TEXT, node.nodeValue

        elif node.nodeType == Node.ELEMENT_NODE:
            attrs = {}
            for attr in list(node.attributes.keys()):
                attr = node.getAttributeNode(attr)
                if attr.namespaceURI:
                    attrs[(attr.namespaceURI, attr.localName)] = attr.value
                else:
                    attrs[(None, attr.name)] = attr.value
            return (base.ELEMENT, node.namespaceURI, node.nodeName,
                    attrs, node.hasChildNodes())

        elif node.nodeType == Node.COMMENT_NODE:
            return base.COMMENT, node.nodeValue

        elif node.nodeType in (Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE):
            return (base.DOCUMENT,)

        else:
            return base.UNKNOWN, node.nodeType 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:28,代碼來源:dom.py

示例5: getNodeDetails

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import CDATA_SECTION_NODE [as 別名]
def getNodeDetails(self, node):
        if node.nodeType == Node.DOCUMENT_TYPE_NODE:
            return _base.DOCTYPE, node.name, node.publicId, node.systemId

        elif node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
            return _base.TEXT, node.nodeValue

        elif node.nodeType == Node.ELEMENT_NODE:
            attrs = {}
            for attr in list(node.attributes.keys()):
                attr = node.getAttributeNode(attr)
                if attr.namespaceURI:
                    attrs[(attr.namespaceURI, attr.localName)] = attr.value
                else:
                    attrs[(None, attr.name)] = attr.value
            return (_base.ELEMENT, node.namespaceURI, node.nodeName,
                    attrs, node.hasChildNodes())

        elif node.nodeType == Node.COMMENT_NODE:
            return _base.COMMENT, node.nodeValue

        elif node.nodeType in (Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE):
            return (_base.DOCUMENT,)

        else:
            return _base.UNKNOWN, node.nodeType 
開發者ID:jpush,項目名稱:jbox,代碼行數:28,代碼來源:dom.py


注:本文中的xml.dom.Node.CDATA_SECTION_NODE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。