当前位置: 首页>>代码示例>>Python>>正文


Python Node.TEXT_NODE属性代码示例

本文整理汇总了Python中xml.dom.minidom.Node.TEXT_NODE属性的典型用法代码示例。如果您正苦于以下问题:Python Node.TEXT_NODE属性的具体用法?Python Node.TEXT_NODE怎么用?Python Node.TEXT_NODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在xml.dom.minidom.Node的用法示例。


在下文中一共展示了Node.TEXT_NODE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SeekToNode

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def SeekToNode(node1, child2):
  # A text node does not have properties.
  if child2.nodeType == Node.TEXT_NODE:
    return None

  # Get the name of the current node.
  current_name = child2.getAttribute("Name")
  if not current_name:
    # There is no name. We don't know how to merge.
    return None

  # Look through all the nodes to find a match.
  for sub_node in node1.childNodes:
    if sub_node.nodeName == child2.nodeName:
      name = sub_node.getAttribute("Name")
      if name == current_name:
        return sub_node

  # No match. We give up.
  return None 
开发者ID:refack,项目名称:GYP3,代码行数:22,代码来源:pretty_vcproj.py

示例2: dumpXML

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def dumpXML(xmlList, phCustId):
    param = []
    for xml in xmlList:
        doc = parseString(xml.encode('utf-8'))
        for node in doc.getElementsByTagName("events"):
            for node1 in node.getElementsByTagName("event"):
                mapping = {}
                for node2 in node1.getElementsByTagName("attributes"):
                    for node3 in node2.getElementsByTagName("attribute"):
                        item_name = node3.getAttribute("name")
                        for node4 in node3.childNodes:
                            if node4.nodeType == Node.TEXT_NODE:
                                mapping[item_name] = node4.data
                    if phCustId == "all" or mapping['phCustId'] == phCustId:
                        param.append(mapping)
    return param 
开发者ID:demisto,项目名称:content,代码行数:18,代码来源:FortiSIEM.py

示例3: get_xml_data

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def get_xml_data(self, dbtype, sql, identifier):
        """
            Get SQL definition from XML file. SQL is retrieved by using keywords passed as function parameters
            @:param dbtype Database type "mysql, mssql, ..."
            @:param sql Sqltype : Select, Create, ...
            @:param identifier Unique Identifier
        """
        result = ""
        xmldoc = xml.dom.minidom.parse(self.xml_path)
        for node in xmldoc.getElementsByTagName(dbtype)[0].getElementsByTagName(sql):
            if node.getAttribute("id") == identifier:
                for child in node.childNodes:
                    if child.nodeType == Node.TEXT_NODE:
                        result = child.data
                        break
        return result 
开发者ID:ActianCorp,项目名称:dbmv,代码行数:18,代码来源:schemaConvertor.py

示例4: testBug0777884

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def testBug0777884(self):
        doc = parseString("<o>text</o>")
        text = doc.documentElement.childNodes[0]
        self.assertEqual(text.nodeType, Node.TEXT_NODE)
        # Should run quietly, doing nothing.
        text.normalize()
        doc.unlink() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_minidom.py

示例5: testWholeText

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def testWholeText(self):
        doc = parseString("<doc>a</doc>")
        elem = doc.documentElement
        text = elem.childNodes[0]
        self.assertEqual(text.nodeType, Node.TEXT_NODE)

        self.checkWholeText(text, "a")
        elem.appendChild(doc.createTextNode("b"))
        self.checkWholeText(text, "ab")
        elem.insertBefore(doc.createCDATASection("c"), text)
        self.checkWholeText(text, "cab")

        # make sure we don't cross other nodes
        splitter = doc.createComment("comment")
        elem.appendChild(splitter)
        text2 = doc.createTextNode("d")
        elem.appendChild(text2)
        self.checkWholeText(text, "cab")
        self.checkWholeText(text2, "d")

        x = doc.createElement("x")
        elem.replaceChild(x, splitter)
        splitter = x
        self.checkWholeText(text, "cab")
        self.checkWholeText(text2, "d")

        x = doc.createProcessingInstruction("y", "z")
        elem.replaceChild(x, splitter)
        splitter = x
        self.checkWholeText(text, "cab")
        self.checkWholeText(text2, "d")

        elem.removeChild(splitter)
        self.checkWholeText(text, "cabd")
        self.checkWholeText(text2, "cabd") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:37,代码来源:test_minidom.py

示例6: get_text_content

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def get_text_content(node):
    text = ''
    for text_node in node.childNodes:
        if text_node.nodeType == Node.TEXT_NODE:
            text += text_node.data
    return text

# The HTML can mostly be saved as-is. The main changes we want to make are:
# 1) Remove most <span>s and attributes since they are not needed anymore.
# 2) Rewrite relative paths ("/Brian-Bi") to full URLs
# 3) Download a copy of each embedded image 
开发者ID:t3nsor,项目名称:quora-backup,代码行数:13,代码来源:converter.py

示例7: Search_MasterTestInfo

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def Search_MasterTestInfo(self, testID, tag):
        """
        Finds the value of given tag in master XML file of Testcase Info (from InitEnv)

        Parameters
        ----------
        testID : str
        tag : tuple of str

        Returns
        -------
        Tag Value (as per XML file) : str
        """
        global MasterTestInfo,doc,uccPath
        result=""

        doc = xml.dom.minidom.parse(uccPath + MasterTestInfo)

        for node in doc.getElementsByTagName(testID):
          L = node.getElementsByTagName(tag)
          for node2 in L:
              for node3 in node2.childNodes:
                  if node3.nodeType == Node.TEXT_NODE:
                      result = node3.nodeValue
                      return result

        return result 
开发者ID:Wi-FiTestSuite,项目名称:Wi-FiTestSuite-UCC,代码行数:29,代码来源:myutils.py

示例8: find_TestcaseInfo_Level1

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def find_TestcaseInfo_Level1(testID, tag):
    """
    Finds the value of given tag in master XML file of Testcase Info

    Parameters
    ----------
    testID : str
    tag : str

    Returns
    -------
    result : int
        tag value as per XML file
    """
    result = ""
    LogMsg("\n|\n|\n| Searching %s for TestID %s" % (tag, testID))
    for node in doc.getElementsByTagName(testID):
        L = node.getElementsByTagName(tag)
        for node2 in L:
            for node3 in node2.childNodes:
                if node3.nodeType == Node.TEXT_NODE:
                    result = node3.nodeValue
                    LogMsg("\n|\n|\n| Found %s = %s" %(tag, result))
                    return result

    LogMsg("\n|\n|\n| Found %s = %s" % (tag, result))
    return result 
开发者ID:Wi-FiTestSuite,项目名称:Wi-FiTestSuite-UCC,代码行数:29,代码来源:InitTestEnv.py

示例9: find_TestbedFile

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def find_TestbedFile(testID):
    result = ""
    LogMsg("\n|\n|\n| Searching Testbed File for TestID %s" % (testID))
    for node in doc.getElementsByTagName(testID):
        L = node.getElementsByTagName("TestbedFile")
        LogMsg("Node1 = %s" % node.nodeName)
        for node2 in L:
            LogMsg("----Node2 = %s" % node2.nodeName)
            for node3 in node2.childNodes:
                if node3.nodeName == "_Value":
                    LogMsg('--------Found %s' % node3.firstChild.nodeValue)
                    result = node3.firstChild.nodeValue
                    break
                if node3.nodeType == Node.TEXT_NODE and node3.nodeValue.isalnum() == True:
                    LogMsg('--------Found -%s-' % node3.nodeValue)
                    if node3.nodeValue == '0':
                        continue
                    else:
                        result = node3.nodeValue
                        break
                else:
                    LogMsg("--------Node3 = %s" % node3.nodeName)
                    if node3.nodeName == dutInfoObject.DUTType:
                        LogMsg("------------Node4 = %s" % node3.firstChild.nodeValue)
                        result = node3.firstChild.nodeValue
                        break

    if result == "NA":
        LogMsg("\n The test %s is not applicable for DUT Type %s" % (testID, dutInfoObject.DUTType))
        VarList.setdefault("TestNA", "The test %s is not applicable for DUT Type %s" % (testID, dutInfoObject.DUTType))
    LogMsg("\n|\n|\n| Found Testbed File -%s-" % (result))
    return result 
开发者ID:Wi-FiTestSuite,项目名称:Wi-FiTestSuite-UCC,代码行数:34,代码来源:InitTestEnv.py

示例10: PrettyPrintNode

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def PrettyPrintNode(node, indent=0):
  if node.nodeType == Node.TEXT_NODE:
    if node.data.strip():
      print('%s%s' % (' '*indent, node.data.strip()))
    return

  if node.childNodes:
    node.normalize()
  # Get the number of attributes
  attr_count = 0
  if node.attributes:
    attr_count = node.attributes.length

  # Print the main tag
  if attr_count == 0:
    print('%s<%s>' % (' '*indent, node.nodeName))
  else:
    print('%s<%s' % (' '*indent, node.nodeName))

    all_attributes = []
    for (name, value) in node.attributes.items():
      all_attributes.append((name, value))
      all_attributes.sort(key=(lambda attr: attr[0]))
    for (name, value) in all_attributes:
      print('%s  %s="%s"' % (' '*indent, name, value))
    print('%s>' % (' '*indent))
  if node.nodeValue:
    print('%s  %s' % (' '*indent, node.nodeValue))

  for sub_node in node.childNodes:
    PrettyPrintNode(sub_node, indent=indent+2)
  print('%s</%s>' % (' '*indent, node.nodeName)) 
开发者ID:refack,项目名称:GYP3,代码行数:34,代码来源:pretty_vcproj.py

示例11: PrettyPrintNode

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def PrettyPrintNode(node, indent=0):
  if node.nodeType == Node.TEXT_NODE:
    if node.data.strip():
      print '%s%s' % (' '*indent, node.data.strip())
    return

  if node.childNodes:
    node.normalize()
  # Get the number of attributes
  attr_count = 0
  if node.attributes:
    attr_count = node.attributes.length

  # Print the main tag
  if attr_count == 0:
    print '%s<%s>' % (' '*indent, node.nodeName)
  else:
    print '%s<%s' % (' '*indent, node.nodeName)

    all_attributes = []
    for (name, value) in node.attributes.items():
      all_attributes.append((name, value))
      all_attributes.sort(CmpTuple())
    for (name, value) in all_attributes:
      print '%s  %s="%s"' % (' '*indent, name, value)
    print '%s>' % (' '*indent)
  if node.nodeValue:
    print '%s  %s' % (' '*indent, node.nodeValue)

  for sub_node in node.childNodes:
    PrettyPrintNode(sub_node, indent=indent+2)
  print '%s</%s>' % (' '*indent, node.nodeName) 
开发者ID:zhaoolee,项目名称:StarsAndClown,代码行数:34,代码来源:pretty_vcproj.py

示例12: remove_blanks

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import TEXT_NODE [as 别名]
def remove_blanks(node):
        for x in node.childNodes:
            if x.nodeType == Node.TEXT_NODE:
                if x.nodeValue:
                    x.nodeValue = x.nodeValue.strip()
            elif x.nodeType == Node.ELEMENT_NODE:
                XMLTypeFuzzer.remove_blanks(x) 
开发者ID:mgeeky,项目名称:burpContextAwareFuzzer,代码行数:9,代码来源:burpContextAwareFuzzer.py


注:本文中的xml.dom.minidom.Node.TEXT_NODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。