Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.
Stay organized with collections Save and categorize content based on your preferences.

google.appengine.ext.bulkload.simplexml_connector module


Bulkloader XML reading and writing.

Handle the XML format specified in a bulkloader.yaml file.


class google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector(xpath_to_nodes, xml_style)source

Bases: google.appengine.ext.bulkload.connector_interface.ConnectorInterface

Read/write a simply-structured XML file and convert dicts for each record.

A simply-structed XML file is one where we can locate all interesting nodes with a simple (ElementTree supported) xpath, and each node contains either all the info we care about as child (and not grandchild) nodes with text or as attributes. We’ll also pass the entire node in case the developer wants to do something more interesting with it (occasional grandchildren, parents, etc.).

This is of course a fairly expensive way to read XML–we build a DOM, then copy parts of it into a dict. A pull model would work well with the interface too.

classmethod create_from_options(options, name)source

Factory using an options dictionary.

  • options – Dictionary of options. Must contain: * xpath_to_nodes: The xpath to select a record. * style: ‘element_centric’ or ‘attribute_centric’

  • name – The name of this transformer, for use in error messages.


XmlConnector connector object described by the specified options.


InvalidConfiguration – If the config is invalid.

generate_import_record(filename, bulkload_state)source

Generator, yields dicts for nodes found as described in the options.

initialize_export(filename, bulkload_state)source

Initialize the output file.


Write one record for the specified entity.


Write a dict as elements, possibly recursively.