Python django.utils.xmlutils.SimplerXMLGenerator() Examples
The following are 30
code examples of django.utils.xmlutils.SimplerXMLGenerator().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.utils.xmlutils
, or try the search function
.
Example #1
Source File: renderers.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
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()
Example #2
Source File: renderers.py From django-rest-framework-xml with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #3
Source File: renderers.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
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()
Example #4
Source File: feedgenerator.py From python2017 with MIT License | 5 votes |
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")
Example #5
Source File: feedgenerator.py From python with Apache License 2.0 | 5 votes |
def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed")
Example #6
Source File: feedgenerator.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
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")
Example #7
Source File: feedgenerator.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed")
Example #8
Source File: xml_serializer.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
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"})
Example #9
Source File: feedgenerator.py From openhgsenti with Apache License 2.0 | 5 votes |
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")
Example #10
Source File: feedgenerator.py From openhgsenti with Apache License 2.0 | 5 votes |
def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed")
Example #11
Source File: export.py From Mxonline3 with Apache License 2.0 | 5 votes |
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]
Example #12
Source File: feedgenerator.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed")
Example #13
Source File: feedgenerator.py From python2017 with MIT License | 5 votes |
def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed")
Example #14
Source File: export.py From imoocc with GNU General Public License v2.0 | 5 votes |
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]
Example #15
Source File: export.py From devops with MIT License | 5 votes |
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]
Example #16
Source File: export.py From online with GNU Affero General Public License v3.0 | 5 votes |
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]
Example #17
Source File: export.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
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]
Example #18
Source File: export.py From ImitationTmall_Django with GNU General Public License v3.0 | 5 votes |
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]
Example #19
Source File: feedgenerator.py From python with Apache License 2.0 | 5 votes |
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")
Example #20
Source File: export.py From StormOnline with Apache License 2.0 | 5 votes |
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]
Example #21
Source File: feedgenerator.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
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")
Example #22
Source File: export.py From django_OA with GNU General Public License v3.0 | 5 votes |
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]
Example #23
Source File: export.py From CTF_AWD_Platform with MIT License | 5 votes |
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]
Example #24
Source File: export.py From myblog with GNU Affero General Public License v3.0 | 5 votes |
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]
Example #25
Source File: renderers.py From cadasta-platform with GNU Affero General Public License v3.0 | 5 votes |
def render(self, data, *args, **kwargs): charset = 'utf-8' root_node = 'xforms' xmlns = "http://openrosa.org/xforms/xformsList" if 'detail' in data.keys(): stream = StringIO() xml = SimplerXMLGenerator(stream, charset) xml.startDocument() xml.startElement(root_node, {'xmlns': xmlns}) for key, value in six.iteritems(data): xml.startElement(key, {}) xml.characters(smart_text(value)) xml.endElement(key) xml.endElement(root_node) xml.endDocument() return stream.getvalue() else: json = self.transform_to_xform_json(data) survey = create_survey_element_from_dict(json) xml = survey.xml() fix_languages(xml) xml = xml.toxml() xml = self.insert_version_attribute(xml, data.get('id_string'), data.get('version')) xml = self.insert_uuid_bind(xml, data.get('id_string')) return xml
Example #26
Source File: renderers.py From rdmo with Apache License 2.0 | 5 votes |
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()
Example #27
Source File: export.py From weibo-analysis-system with MIT License | 5 votes |
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]
Example #28
Source File: feedgenerator.py From bioforum with MIT License | 5 votes |
def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed")
Example #29
Source File: feedgenerator.py From bioforum with MIT License | 5 votes |
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")
Example #30
Source File: xml_serializer.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
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"})