• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dom.unlink函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xml.dom.unlink函数的典型用法代码示例。如果您正苦于以下问题:Python unlink函数的具体用法?Python unlink怎么用?Python unlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testLegalChildren

def testLegalChildren():
    dom = Document()
    elem = dom.createElement('element')
    text = dom.createTextNode('text')

    try: dom.appendChild(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    dom.appendChild(elem)
    try: dom.insertBefore(text, elem)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    try: dom.replaceChild(text, elem)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    nodemap = elem.attributes
    try: nodemap.setNamedItem(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr"

    try: nodemap.setNamedItemNS(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr"

    elem.appendChild(text)
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:34,代码来源:test_minidom.py


示例2: load

	def load(self):
		d1 = self.dbhelper.dbRead(self.om_db, "xml_date")
		d2 = os.stat(self.defFile).st_mtime
		print "XML_CSL_LOAD", d1, d2
		if d1 != None:
			if d1 > d2:
				# FIXME: hata vermek yerine db'leri sifirlayip yeniden olustur
				print "XML_CSL: OOPS, xml om definition is newer than om db"
				print "XML_CSL: please remove db files manually"
				return
			else:
				return
		print "XML_CSL: creating om DBs..."
		try:
			dom = xml.dom.minidom.parse(self.defFile)
		except:
			print "OMDB: cannot parse '%s'" % (self.defFile)
			return 0
		if dom.documentElement.localName != "comar-om":
			print "OMDB: '%s' is not a COMAR om dtd" % (self.defFile)
			return 0
		ns = dom.getElementsByTagName("namespace")[0]
		# FIXME: namespace in useNS ile ayni oldugunu dogrula
		self.namespace = ns.getAttribute("name")
		print "Adding OM Keys:",
		for node in ns.childNodes:
			self.load_node(node)
			
		dom.unlink()
		if d1 == None:
			self.dbhelper.dbWrite(self.om_db, "xml_date", str(d2))
		return 1
开发者ID:Tayyib,项目名称:uludag,代码行数:32,代码来源:XML_CSL.py


示例3: testAppendChildFragment

def testAppendChildFragment():
    dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes()
    dom.documentElement.appendChild(frag)
    confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3),
            "appendChild(<fragment>)")
    frag.unlink()
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:7,代码来源:test_minidom.py


示例4: _testElementReprAndStrUnicode

def _testElementReprAndStrUnicode():
    dom = Document()
    el = dom.appendChild(dom.createElement(u"abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:7,代码来源:test_minidom.py


示例5: testAAB

def testAAB():
    dom = parseString("<abc/>")
    el = dom.documentElement
    el.setAttribute("spam", "jam")
    el.setAttribute("spam", "jam2")
    confirm(el.toxml() == '<abc spam="jam2"/>', "testAAB")
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:7,代码来源:test_minidom.py


示例6: __init__

    def __init__(self, string):
        object.__init__(self)

        dom = parseString(string)
        self.root = XMLGroup(dom.documentElement.tagName)
        self.root.load_xml(dom.documentElement)
        dom.unlink()
开发者ID:cmotc,项目名称:medit,代码行数:7,代码来源:_xml.py


示例7: load_persistent_configuration

    def load_persistent_configuration(self):
        (dom, element) = self.find_own_dom_element()

        configuration = enter_named_element(element, 'configuration')
        if configuration and self.configuration is not None:
            self.configuration.set_from_dom_node(configuration)
        dom.unlink()
开发者ID:lumig242,项目名称:VisTrailsRecommendation,代码行数:7,代码来源:package.py


示例8: getDomains

def getDomains(targets,release):
  import urllib
  from xml.dom.minidom import parse  
  import xml.dom
  import pickle
  pfamDict ={}
  

  ## Loop through all targets and get pfam domains.
  errors = []
  for target in targets:
    #print "getting Pfam domains for %s" % target
    pfamDict[target] = {}
    pfamDict[target]["domains"] = []
    pfamDict[target]["start"] = []
    pfamDict[target]["end"] = []
    opener = urllib.FancyURLopener({})                                     
    f = opener.open("http://pfam.sanger.ac.uk/protein/%s?output=xml" % target) 
    dom = parse(f)
    if not dom.getElementsByTagName('sequence'):
      #print "encountered Error for %s" %target
      errors.append(target)
      del pfamDict[target]
      continue

    
    for pfam in dom.childNodes:
      if pfam.nodeName == 'pfam':
        for entry in pfam.childNodes:
          if entry.nodeName == 'entry':
            for matches in entry.childNodes:
              if matches.nodeName == 'matches':
                for match in matches.childNodes:
                  if match.nodeName == 'match':
                    if match.getAttribute('type') == 'Pfam-A':
                      pfamDict[target]['domains'].append(match.getAttribute('id'))
                      for location in match.childNodes:
                        if location.nodeName == 'location':
                          start = location.getAttribute('start')
                          end = location.getAttribute('end')
                          pfamDict[target]['start'].append(int(start))
                          pfamDict[target]['end'].append(int(end))
    dom.unlink()
    
    # Add domain count.
    pfamDict[target]['count'] = len(pfamDict[target]['domains'])
    
    # Calculate and add the uniq count of domains. 
    uniqDomains = {}
    for domain in pfamDict[target]['domains']:
      uniqDomains[domain] = 0   
    pfamDict[target]['countUnique'] = len(uniqDomains)
    
  ## Pickle the PfamDict
  output = open('data/protCodPfamDict_%s.pkl' %release, 'w')
  pickle.dump(pfamDict, output)

  print "encountered Error for", errors
  return pfamDict   
开发者ID:MoSander,项目名称:mapChEMBLPfam,代码行数:59,代码来源:getPfamDomains.py


示例9: set_persistent_configuration

 def set_persistent_configuration(self):
     (dom, element) = self.find_own_dom_element()
     child = enter_named_element(element, 'configuration')
     if child:
         element.removeChild(child)
     self.configuration.write_to_dom(dom, element)
     get_vistrails_application().vistrailsStartup.write_startup_dom(dom)
     dom.unlink()
开发者ID:lumig242,项目名称:VisTrailsRecommendation,代码行数:8,代码来源:package.py


示例10: testReplaceChildFragment

def testReplaceChildFragment():
    dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes()
    dom.documentElement.replaceChild(frag, orig)
    orig.unlink()
    confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3),
            "replaceChild(<fragment>)")
    frag.unlink()
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:8,代码来源:test_minidom.py


示例11: parse_from_xml

 def parse_from_xml(self, xml_spec):
     '''Parse a string or file containing an XML specification.'''
     if type(xml_spec) in string_types():
         dom = xml.dom.minidom.parseString(xml_spec)
     else:
         dom = xml.dom.minidom.parse(xml_spec)
     self._parse_xml(dom)
     dom.unlink()
开发者ID:sugarsweetrobotics,项目名称:rtsprofile,代码行数:8,代码来源:rts_profile.py


示例12: testCloneElementShallow

def testCloneElementShallow():
    dom, clone = _setupCloneElement(0)
    confirm(len(clone.childNodes) == 0
            and clone.childNodes.length == 0
            and clone.parentNode is None
            and clone.toxml() == '<doc attr="value"/>'
            , "testCloneElementShallow")
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:8,代码来源:test_minidom.py


示例13: testCloneElementDeep

def testCloneElementDeep():
    dom, clone = _setupCloneElement(1)
    confirm(len(clone.childNodes) == 1
            and clone.childNodes.length == 1
            and clone.parentNode is None
            and clone.toxml() == '<doc attr="value"><foo/></doc>'
            , "testCloneElementDeep")
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:8,代码来源:test_minidom.py


示例14: _testElementReprAndStrUnicodeNS

def _testElementReprAndStrUnicodeNS():
    dom = Document()
    el = dom.appendChild(
        dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    confirm(string1.find("slash:abc") != -1)
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:9,代码来源:test_minidom.py


示例15: testDeleteAttr

def testDeleteAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    confirm(len(child.attributes) == 0)
    child.setAttribute("def", "ghi")
    confirm(len(child.attributes) == 1)
    del child.attributes["def"]
    confirm(len(child.attributes) == 0)
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:10,代码来源:test_minidom.py


示例16: testRemoveAttr

def testRemoveAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    child.setAttribute("def", "ghi")
    confirm(len(child.attributes) == 1)
    child.removeAttribute("def")
    confirm(len(child.attributes) == 0)

    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:10,代码来源:test_minidom.py


示例17: testAAA

def testAAA():
    dom = parseString("<abc/>")
    el = dom.documentElement
    el.setAttribute("spam", "jam2")
    confirm(el.toxml() == '<abc spam="jam2"/>', "testAAA")
    a = el.getAttributeNode("spam")
    confirm(a.ownerDocument is dom,
            "setAttribute() sets ownerDocument")
    confirm(a.ownerElement is dom.documentElement,
            "setAttribute() sets ownerElement")
    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:11,代码来源:test_minidom.py


示例18: importXML

 def importXML(path):
     logDebug("Importing data from "+str(path))
     try:
         dom = xml.dom.minidom.parse(path)
         document = XMLDocHRModuleImport(dom);            
         #document.debug()
         dom.unlink()
         return document
     except:
         logError(_("Importing failed."))
         return None
开发者ID:GunioRobot,项目名称:Einstein-AEE-outdated-,代码行数:11,代码来源:importHR.py


示例19: testRemoveAttributeNode

def testRemoveAttributeNode():
    dom = Document()
    child = dom.appendChild(dom.createElement("foo"))
    child.setAttribute("spam", "jam")
    confirm(len(child.attributes) == 1)
    node = child.getAttributeNode("spam")
    child.removeAttributeNode(node)
    confirm(len(child.attributes) == 0
            and child.getAttributeNode("spam") is None)

    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:11,代码来源:test_minidom.py


示例20: testRemoveAttrNS

def testRemoveAttrNS():
    dom = Document()
    child = dom.appendChild(
            dom.createElementNS("http://www.python.org", "python:abc"))
    child.setAttributeNS("http://www.w3.org", "xmlns:python",
                                            "http://www.python.org")
    child.setAttributeNS("http://www.python.org", "python:abcattr", "foo")
    confirm(len(child.attributes) == 2)
    child.removeAttributeNS("http://www.python.org", "abcattr")
    confirm(len(child.attributes) == 1)

    dom.unlink()
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:12,代码来源:test_minidom.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python HTMLElement.HTMLElement类代码示例发布时间:2022-05-26
下一篇:
Python dom.getElementsByTagName函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap