当前位置: 首页>>代码示例>>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;未经允许,请勿转载。