當前位置: 首頁>>代碼示例>>Python>>正文


Python minidom._write_data方法代碼示例

本文整理匯總了Python中xml.dom.minidom._write_data方法的典型用法代碼示例。如果您正苦於以下問題:Python minidom._write_data方法的具體用法?Python minidom._write_data怎麽用?Python minidom._write_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xml.dom.minidom的用法示例。


在下文中一共展示了minidom._write_data方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _writexml_text

# 需要導入模塊: from xml.dom import minidom [as 別名]
# 或者: from xml.dom.minidom import _write_data [as 別名]
def _writexml_text(self, writer, indent="", addindent="", newl=""):
        minidom._write_data(writer, "%s"%(self.data.strip())) 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:4,代碼來源:prettyprint.py

示例2: _writexml_element

# 需要導入模塊: from xml.dom import minidom [as 別名]
# 或者: from xml.dom.minidom import _write_data [as 別名]
def _writexml_element(self, writer, indent="", addindent="", newl=""):
        # indent = current indentation
        # addindent = indentation to add to higher levels
        # newl = newline string
        writer.write(indent+"<" + self.tagName)

        attrs = self._get_attributes()
        a_names = attrs.keys()
        a_names.sort()

        for a_name in a_names:
                writer.write(" %s=\"" % a_name)
                minidom._write_data(writer, attrs[a_name].value)
                writer.write("\"")
        if self.childNodes:
                if self.childNodes[0].nodeType == Node.TEXT_NODE and len(self.childNodes[0].data) > 0:
                        writer.write(">")
                else:
                        writer.write(">%s"%(newl))
                for node in self.childNodes:
                        node.writexml(writer,indent+addindent,addindent,newl)
                if self.childNodes[-1].nodeType == Node.TEXT_NODE and len(self.childNodes[0].data) > 0:
                        writer.write("</%s>%s" % (self.tagName,newl))
                else:
                        writer.write("%s</%s>%s" % (indent,self.tagName,newl))
        else:
                writer.write("/>%s"%(newl)) 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:29,代碼來源:prettyprint.py

示例3: fixed_writexml

# 需要導入模塊: from xml.dom import minidom [as 別名]
# 或者: from xml.dom.minidom import _write_data [as 別名]
def fixed_writexml(self, writer, indent="", addindent="", newl=""):
    # indent = current indentation
    # addindent = indentation to add to higher levels
    # newl = newline string
    writer.write(indent+"<" + self.tagName)

    attrs = self._get_attributes()
    a_names = attrs.keys()
    a_names.sort()

    for a_name in a_names:
        writer.write(" %s=\"" % a_name)
        minidom._write_data(writer, attrs[a_name].value)
        writer.write("\"")
    if self.childNodes:
        if len(self.childNodes) == 1 \
          and self.childNodes[0].nodeType == minidom.Node.TEXT_NODE:
            writer.write(">")
            self.childNodes[0].writexml(writer, "", "", "")
            writer.write("</%s>%s" % (self.tagName, newl))
            return
        writer.write(">%s"%(newl))
        for node in self.childNodes:
            if node.nodeType is not minidom.Node.TEXT_NODE:
                node.writexml(writer,indent+addindent,addindent,newl)
        writer.write("%s</%s>%s" % (indent,self.tagName,newl))
    else:
        writer.write("/>%s"%(newl))
# replace minidom's function with ours 
開發者ID:taxigps,項目名稱:xbmc-addons-chinese,代碼行數:31,代碼來源:default.py

示例4: monkeypatch_element_xml

# 需要導入模塊: from xml.dom import minidom [as 別名]
# 或者: from xml.dom.minidom import _write_data [as 別名]
def monkeypatch_element_xml(self, writer, indent="", addindent="", newl=""):
    """Format scenario step elements.

    Ensures a stable and predictable order to the attributes of these
    elements with the most important information always coming first,
    then let all other elements follow in alphabetical order.
    """
    writer.write("{}<{}".format(indent, self.tagName))

    attrs = self._get_attributes()
    a_names = sorted(attrs.keys(), key=AttributeSorter)

    for a_name in a_names:
        writer.write(" {}=\"".format(a_name))
        minidom._write_data(writer, attrs[a_name].value)
        writer.write("\"")
    if self.childNodes:
        writer.write(">")
        if (len(self.childNodes) == 1 and
                self.childNodes[0].nodeType == Node.TEXT_NODE):
            self.childNodes[0].writexml(writer, '', '', '')
        else:
            writer.write(newl)
            for node in self.childNodes:
                node.writexml(writer, indent+addindent, addindent, newl)
            writer.write(indent)
        writer.write("</{}>{}".format(self.tagName, newl))
    else:
        writer.write("/>{}".format(newl)) 
開發者ID:SIPp,項目名稱:pysipp,代碼行數:31,代碼來源:minidom.py


注:本文中的xml.dom.minidom._write_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。