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 |
Undocumented |
Function | _add |
Undocumented |
Build an XML element from arguments.
Parameters | |
names:str | A tag name or names. |
*args | A collection of args. |
**kwargs | Additional attributes. |
Returns | |
gws.IXmlElement | An XML element. |