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


Python Document.ownerDocument方法代码示例

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


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

示例1: save_xml

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import ownerDocument [as 别名]
 def save_xml(self, xmlparent=None):
     typ = self.nodetype()
     if xmlparent is None:
         assert typ == Document.DOCUMENT_NODE
         xmlnode = Document()
         xmlnode.ownerDocument = xmlnode
     else:
         if typ == Document.ATTRIBUTE_NODE:
             xmlnode = xmlparent.ownerDocument.createAttribute(self.name())
         elif typ == Document.CDATA_SECTION_NODE:
             xmlnode = xmlparent.ownerDocument.createCDATASection()
         elif typ == Document.COMMENT_NODE:
             xmlnode = xmlparent.ownerDocument.createComment(self.attribute("data"))
         elif typ == Document.DOCUMENT_FRAGMENT_NODE:
             xmlnode = xmlparent.ownerDocument.createDocumentFragment()
         elif typ == Document.DOCUMENT_NODE:
             raise UserWarning("cannot create a DOCUMENT_NODE from there")
         elif typ == Document.DOCUMENT_TYPE_NODE:
             raise UserWarning("cannot create a DOCUMENT_TYPE_NODE from there")
         elif typ == Document.ELEMENT_NODE:
             xmlnode = xmlparent.ownerDocument.createElement(self.nodename())
             for key in self.attributes():
                 xmlnode.setAttribute(key, self.attribute(key))
         elif typ == Document.ENTITY_NODE:
             raise UserWarning("cannot create a ENTITY_NODE from there")
         elif typ == Document.ENTITY_REFERENCE_NODE:
             raise UserWarning("cannot create a ENTITY_REFERENCE_NODE from there")
         elif typ == Document.NOTATION_NODE:
             raise UserWarning("cannot create a NOTATION_NODE from there")
         elif typ == Document.PROCESSING_INSTRUCTION_NODE:
             xmlnode = xmlparent.ownerDocument.createProcessingInstruction()
         elif typ == Document.TEXT_NODE:
             xmlnode = xmlparent.ownerDocument.createTextNode(self.attribute("data"))
         else:
             raise UserWarning("problem")
             # xml tree save
         xmlparent.appendChild(xmlnode)
     for child in self.children():
         child.save_xml(xmlnode)
     return xmlnode
开发者ID:VirtualPlants,项目名称:openalea-components,代码行数:42,代码来源:xml_element.py


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