當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。