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


Python minidom.getDOMImplementation方法代码示例

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


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

示例1: render_GET

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def render_GET(self, request):
        """
        Render as HTML a listing of all known users with links to their
        personal resources.
        """

        domImpl = getDOMImplementation()
        newDoc = domImpl.createDocument(None, "ul", None)
        listing = newDoc.documentElement
        for link, text in self._users():
            linkElement = newDoc.createElement('a')
            linkElement.setAttribute('href', link + '/')
            textNode = newDoc.createTextNode(text)
            linkElement.appendChild(textNode)
            item = newDoc.createElement('li')
            item.appendChild(linkElement)
            listing.appendChild(item)

        htmlDoc = self.template % ({'users': listing.toxml()})
        return htmlDoc.encode("utf-8") 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:22,代码来源:distrib.py

示例2: set_settings

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def set_settings(JsonRespuesta):
    for Ajuste in JsonRespuesta:
        settings_dic[Ajuste] = JsonRespuesta[Ajuste].encode("utf8")
    from xml.dom import minidom
    # Crea un Nuevo XML vacio
    new_settings = minidom.getDOMImplementation().createDocument(None, "settings", None)
    new_settings_root = new_settings.documentElement

    for key in settings_dic:
        nodo = new_settings.createElement("setting")
        nodo.setAttribute("value", settings_dic[key])
        nodo.setAttribute("id", key)
        new_settings_root.appendChild(nodo)

    fichero = open(configfilepath, "w")
    fichero.write(new_settings.toprettyxml(encoding='utf-8'))
    fichero.close()


# Fichero de configuración 
开发者ID:alfa-addon,项目名称:addon,代码行数:22,代码来源:config.py

示例3: __init__

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def __init__(self, cls, db_name, db_user, db_passwd,
                 db_host, db_port, db_table, ddl_dir, enable_ssl):
        self.cls = cls
        if not db_name:
            db_name = cls.__name__.lower()
        self.db_name = db_name
        self.db_user = db_user
        self.db_passwd = db_passwd
        self.db_host = db_host
        self.db_port = db_port
        self.db_table = db_table
        self.ddl_dir = ddl_dir
        self.s3 = None
        self.converter = XMLConverter(self)
        self.impl = getDOMImplementation()
        self.doc = self.impl.createDocument(None, 'objects', None)

        self.connection = None
        self.enable_ssl = enable_ssl
        self.auth_header = None
        if self.db_user:
            base64string = encodebytes('%s:%s' % (self.db_user, self.db_passwd))[:-1]
            authheader = "Basic %s" % base64string
            self.auth_header = authheader 
开发者ID:VirtueSecurity,项目名称:aws-extender,代码行数:26,代码来源:xmlmanager.py

示例4: set_settings

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def set_settings(JsonRespuesta):
    for Ajuste in JsonRespuesta:
      settings_dic[Ajuste]=JsonRespuesta[Ajuste].encode("utf8")
    from xml.dom import minidom
    #Crea un Nuevo XML vacio
    new_settings = minidom.getDOMImplementation().createDocument(None, "settings", None)
    new_settings_root = new_settings.documentElement
    
    for key in settings_dic:
      nodo = new_settings.createElement("setting")
      nodo.setAttribute("value",settings_dic[key])
      nodo.setAttribute("id",key)    
      new_settings_root.appendChild(nodo)
      
    fichero = open(configfilepath, "w")
    fichero.write(new_settings.toprettyxml(encoding='utf-8'))
    fichero.close()



# Fichero de configuración 
开发者ID:pelisalacarta-ce,项目名称:pelisalacarta-ce,代码行数:23,代码来源:config.py

示例5: __init__

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def __init__(self, cls, db_name, db_user, db_passwd,
                 db_host, db_port, db_table, ddl_dir, enable_ssl):
        self.cls = cls
        if not db_name:
            db_name = cls.__name__.lower()
        self.db_name = db_name
        self.db_user = db_user
        self.db_passwd = db_passwd
        self.db_host = db_host
        self.db_port = db_port
        self.db_table = db_table
        self.ddl_dir = ddl_dir
        self.s3 = None
        self.converter = XMLConverter(self)
        self.impl = getDOMImplementation()
        self.doc = self.impl.createDocument(None, 'objects', None)

        self.connection = None
        self.enable_ssl = enable_ssl
        self.auth_header = None
        if self.db_user:
            import base64
            base64string = base64.encodestring('%s:%s' % (self.db_user, self.db_passwd))[:-1]
            authheader =  "Basic %s" % base64string
            self.auth_header = authheader 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:27,代码来源:xmlmanager.py

示例6: create_doc_without_doctype

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_minidom.py

示例7: create_nonempty_doctype

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_minidom.py

示例8: testRenameOther

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_minidom.py

示例9: test_original_escape_escapes_more_than_necessary

# 需要导入模块: from xml.dom import minidom [as 别名]
# 或者: from xml.dom.minidom import getDOMImplementation [as 别名]
def test_original_escape_escapes_more_than_necessary(self):
        """Should fail if the original is updated (the patch can be removed)."""
        text = "' \" & < >"
        expected = "<root>' &quot; &amp; &lt; &gt;</root>".format(text)
        document = getDOMImplementation().createDocument(None, "root", None)
        root = document.documentElement
        text_node = document.createTextNode(text)
        root.appendChild(text_node)
        observed = root.toprettyxml(indent="", newl="")
        self.assertEqual(expected, observed) 
开发者ID:XLSForm,项目名称:pyxform,代码行数:12,代码来源:xml_tests.py


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