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