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


Python xmlutils.SimplerXMLGenerator方法代码示例

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


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

示例1: render

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Renders *obj* into serialized XML.
        """
        if data is None:
            return ''
        elif isinstance(data, six.string_types):
            return data

        stream = StringIO()

        xml = SimplerXMLGenerator(stream, self.charset)
        xml.startDocument()
        xml.startElement(self.root_node, {'xmlns': self.xmlns})

        self._to_xml(xml, data)

        xml.endElement(self.root_node)
        xml.endDocument()

        return stream.getvalue() 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:23,代码来源:renderers.py

示例2: render

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Renders `data` into serialized XML.
        """
        if data is None:
            return ""

        stream = StringIO()

        xml = SimplerXMLGenerator(stream, self.charset)
        xml.startDocument()
        xml.startElement(self.root_tag_name, {})

        self._to_xml(xml, data)

        xml.endElement(self.root_tag_name)
        xml.endDocument()
        return stream.getvalue() 
开发者ID:jpadilla,项目名称:django-rest-framework-xml,代码行数:20,代码来源:renderers.py

示例3: render

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Renders *obj* into serialized XML.
        """
        # if data is None:
        #     return ''
        # elif isinstance(data, six.string_types):
        #     return data

        stream = StringIO()

        xml = SimplerXMLGenerator(stream, self.charset)
        xml.startDocument()
        xml.startElement(self.root_node, {'xmlns': self.xmlns})

        self._to_xml(xml, data)
        xml.endElement(self.root_node)
        xml.endDocument()
        return stream.getvalue() 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:21,代码来源:renderers.py

示例4: get_xml_export

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def get_xml_export(self, context):
        results = self._get_objects(context)
        stream = io.StringIO()

        xml = SimplerXMLGenerator(stream, "utf-8")
        xml.startDocument()
        xml.startElement("objects", {})

        self._to_xml(xml, results)

        xml.endElement("objects")
        xml.endDocument()

        return stream.getvalue().split('\n')[1] 
开发者ID:stormsha,项目名称:StormOnline,代码行数:16,代码来源:export.py

示例5: write

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def write(self, outfile, encoding):
        handler = SimplerXMLGenerator(outfile, encoding)
        handler.startDocument()
        handler.startElement("rss", self.rss_attributes())
        handler.startElement("channel", self.root_attributes())
        self.add_root_elements(handler)
        self.write_items(handler)
        self.endChannelElement(handler)
        handler.endElement("rss") 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:11,代码来源:feedgenerator.py

示例6: start_serialization

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def start_serialization(self):
        """
        Start serialization -- open the XML document and the root element.
        """
        self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET))
        self.xml.startDocument()
        self.xml.startElement("django-objects", {"version": "1.0"}) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:9,代码来源:xml_serializer.py

示例7: render

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def render(self, data):

        if data is None:
            return ''

        stream = StringIO()

        xml = SimplerXMLGenerator(stream, "utf-8")
        xml.startDocument()
        self.render_document(xml, data)
        xml.endDocument()
        return stream.getvalue() 
开发者ID:rdmorganiser,项目名称:rdmo,代码行数:14,代码来源:renderers.py

示例8: start_serialization

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def start_serialization(self):
        """
        Start serialization -- open the XML document and the root element.
        """
        self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET))
        self.xml.startDocument()
        self.xml.startElement("django-objects", {"version" : "1.0"}) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:9,代码来源:xml_serializer.py

示例9: get_xml_export

# 需要导入模块: from django.utils import xmlutils [as 别名]
# 或者: from django.utils.xmlutils import SimplerXMLGenerator [as 别名]
def get_xml_export(self, context):
        results = self._get_objects(context)
        stream = StringIO.StringIO()

        xml = SimplerXMLGenerator(stream, "utf-8")
        xml.startDocument()
        xml.startElement("objects", {})

        self._to_xml(xml, results)

        xml.endElement("objects")
        xml.endDocument()

        return stream.getvalue().split('\n')[1] 
开发者ID:madre,项目名称:devops,代码行数:16,代码来源:export.py


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