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


Python Node.TEXT_NODE屬性代碼示例

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


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

示例1: character_data_handler_cdata

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_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: _handle_white_text_nodes

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_NODE [as 別名]
def _handle_white_text_nodes(self, node, info):
        if (self._options.whitespace_in_element_content
            or not info.isElementContent()):
            return

        # We have element type information and should remove ignorable
        # whitespace; identify for text nodes which contain only
        # whitespace.
        L = []
        for child in node.childNodes:
            if child.nodeType == TEXT_NODE and not child.data.strip():
                L.append(child)

        # Remove ignorable whitespace from the tree.
        for child in L:
            node.removeChild(child) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:18,代碼來源:expatbuilder.py

示例3: character_data_handler_cdata

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_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

示例4: getNodeDetails

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_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

示例5: _element2dict

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_NODE [as 別名]
def _element2dict(self, parent):
        """
        將單個節點轉換為 dict
        """
        d = {}
        for node in parent.childNodes:
            if not isinstance(node, minidom.Element):
                continue
            if not node.hasChildNodes():
                continue

            if node.childNodes[0].nodeType == minidom.Node.ELEMENT_NODE:
                try:
                    d[node.tagName]
                except KeyError:
                    d[node.tagName] = []
                d[node.tagName].append(self._element2dict(node))
            elif len(node.childNodes) == 1 and node.childNodes[0].nodeType in [minidom.Node.CDATA_SECTION_NODE, minidom.Node.TEXT_NODE]:
                d[node.tagName] = node.childNodes[0].data
        return d 
開發者ID:doraemonext,項目名稱:wechat-python-sdk,代碼行數:22,代碼來源:parser.py

示例6: character_data_handler

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

示例7: getNodeDetails

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_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

示例8: getNodeDetails

# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import TEXT_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

示例9: character_data_handler

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


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