Base XML Dumper¶
Note
Do not use the XML
directly.
dictdumper.xml
contains XML
only, which dumpers an extensible markup language (XML) format
file. Usage sample is described as below.
>>> dumper = XML(file_name)
>>> dumper(content_dict_1, name=content_name_1)
>>> dumper(content_dict_2, name=content_name_2)
............
Todo
Supports more
dtd
of XML.
Dumper class¶
- class dictdumper.xml.XML(fname, **kwargs)[source]¶
Bases:
Dumper
Dump extensible markup language (XML) file.
Note
This is a base dumper for XML format. No
dtd
supported.>>> dumper = XML(file_name) >>> dumper(content_dict_1, name=content_name_1) >>> dumper(content_dict_2, name=content_name_2) ............
- Variables:
_file (str) – output file name
_sptr (int) – indicates start of appending point (file pointer)
_tctr (int) – tab level counter
_hsrt (str) – start string (
_HEADER_START
)_hend (str) – end string (
_HEADER_END
)
- _hsrt = '<?xml version="1.0" encoding="UTF-8"?>\n<content>\n'¶
XML head string.
- _hend = '</content>\n'¶
XML tail string.
- property kind¶
File format of current dumper.
- Return type:
Literal[‘xml’]
- abstract _append_value(value, file, name)[source]¶
Call this function to write contents.
- Parameters:
value (Dict[str, Any]) – content to be dumped
file (io.TextIOWrapper) – output file
name (str) – name of current content block
Internal utilities¶
- dictdumper.xml._HEADER_START = '<?xml version="1.0" encoding="UTF-8"?>\n<content>\n'¶
XML head string.
- dictdumper.xml._HEADER_END = '</content>\n'¶
XML tail string.