本文整理汇总了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")
示例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
示例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
示例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
示例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
示例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)
示例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
示例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()
示例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>' " & < ></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)