module documentation

XML builder.

This module provides a single function tag, which creates an Xml Element from a list of arguments.

The first argument to this function is interpreted as a tag name or a slash separated list of tag names, in which case nested elements are created.

The remaining *args are interpreted as follows:

  • a simple value (string, number) - appended to the text content of the Element
  • an Xml Element - appended as a child to the Element
  • a dict - attributes of the Element are updated from this dict
  • a list, tuple or a generator - used as arguments to tag to create a child tag

If keyword arguments are given, they are added to the Element's attributes.

Example:

tag(
    'geometry/gml:Point',
    {'gml:id': 'xy'},
    ['gml:coordinates', '12.345,56.789'],
    srsName=3857,
)

creates the following element:

<geometry>
    <gml:Point gml:id="xy" srsName="3857">
        <gml:coordinates>12.345,56.789</gml:coordinates>
    </gml:Point>
</geometry>
Function tag Build an XML element from arguments.
Function _add Undocumented
Function _add_list Undocumented
Function _add_text Undocumented
def tag(names: str, *args, **kwargs) -> gws.IXmlElement: (source)

Build an XML element from arguments.

Parameters
names:strA tag name or names.
*argsA collection of args.
**kwargsAdditional attributes.
Returns
gws.IXmlElementAn XML element.
def _add(el: gws.IXmlElement, arg): (source)

Undocumented

def _add_list(el, ls): (source)

Undocumented

def _add_text(el, s): (source)

Undocumented