maci docs
  • maci
  • WATCH
    • Quick Start
    • Full Training Series
  • DOCS
    • maci
      • language
        • v1.0.0
      • functions
        • maci.build
        • maci.load
        • maci.loadstr
        • maci.loadattrs
        • maci.loadraw
        • maci.loaddict
        • maci.loadstrdict
        • maci.dump
        • maci.dumpstr
        • maci.dumpraw
      • object
        • methods
          • lock_attr
          • unlock_attr
          • hard_lock_attr
          • map_attr
          • unmap_attr
          • load_attrs
          • get_attrs
          • get_locked_list
          • get_hard_locked_list
          • get_all_maps
          • get_parent_maps
          • get_child_maps
          • get_parent_map_chains
          • is_parent_map
          • is_child_map
      • errors
      • hints
    • json
      • functions
        • maci.jsonload
        • maci.jsonloadstr
        • maci.jsondump
        • maci.jsondumpstr
    • yaml
      • functions
        • maci.yamlload
        • maci.yamlloadstr
        • maci.yamlloadall
        • maci.yamldump
        • maci.yamldumpstr
        • maci.yamldumpall
    • toml
      • functions
        • maci.tomlload
        • maci.tomlloadstr
        • maci.tomldump
        • maci.tomldumpstr
    • ini
      • functions
        • maci.iniload
        • maci.inidump
        • maci.inibuildauto
        • maci.inibuildmanual
    • xml
      • functions
        • maci.xmlload
        • maci.xmlloadstr
        • maci.xmlloaddict
        • maci.xmlloadstrdict
        • maci.xmldump
        • maci.xmldumpstr
        • maci.xmldumpdict
        • maci.xmldumpstrdict
        • maci.xmlbuildmanual
        • maci._defuse_xml_stdlib
    • pickle
      • functions
        • maci.pickleloadbytes
        • maci.pickledumpbytes
    • tools
      • hash functions
        • maci.createhash
        • maci.createfilehash
        • maci.comparefilehash
      • format functions
        • maci.cleanformat
  • Updates
    • Changelog
      • v1.1.0
      • v1.0.0
Powered by GitBook
On this page
  • dumping a file
  • partner functions
  • parameters & arguments
  1. DOCS
  2. xml
  3. functions

maci.xmldump

dumps element or elementtree data to a file as xml

Last updated 1 year ago

dumping a file

Dumps or object data to a file formatted as XML. Nothing is returned. Creates a new or overwrites an existing file by default (See to change mode).

Basic Example of dumping data to a file using default positional parameters

maci.xmldump('mydata.xml', data)

In this example, we simply dump data to a file using the xmldump function and pass a string of the filepath to the file as the first argument to the function, then pass the data as the second argument to the function.

To learn more about building out your xml ElementTree data in code, see More information on using Element and ElementTree data: Youtube Video Search: Documentation:

partner functions

Functions that are related for ElementTree

-> Loads xml data from a file as Element or ElementTree object -> Loads xml data from a string as Element object -> Dumps xml data to a string from xml etree Element object -> Returns empty xml ElementTree object to manually build xml data -> Monkey patch and defuse all stdlib packages [security use]

parameters & arguments

Describes all parameter functionality and accepted data types

filename: str | Path

First required positional argument. Accepts strings and

Use this parameter to point to your filepath

data: ElementTree | Element

Use this parameter to pass in the data you want to dump to a file.

append: bool

Optional parameter. Accepts booleans. Default = False. File must already exist.

Use this parameter to enable appending mode to write by appending data to the file. Default is disabled which writes new or overwrites a file.

encoding: str | None

Optional parameter. Accepts strings or None. Default = None

Use this parameter to dump the data with the desired codec of the data if needed. The default uses the default of python, so you don't have to use this, but you can if the data needs to be written with a specific codec.

Security awareness: It is important to evaluate handling XML data carefully as there are known vulnerabilities in dealing with XML data. Please refer to the official python documentation above.

Second required positional argument. Accepts or objects

This function uses the native xml library etree shipped with the python standard library for its underlying functionality. For more information on the xml.etree api, visit:

Additionally, see the provided tooling to potentially assist with vulnerabilities

Element
ElementTree
append parameter
xmlbuildmanual
https://www.youtube.com/results?search_query=python+xml+etree
https://docs.python.org/3/library/xml.etree.elementtree.html
maci.xmlload
maci.xmlloadstr
maci.xmldumpstr
maci.xmlbuildmanual
maci._defuse_xml_stdlib
Path objects
ElementTree
Element
https://docs.python.org/3/library/xml.etree.elementtree.html
_defuse_xml_stdlib