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 string
  • partner functions
  • parameters & arguments
  1. DOCS
  2. xml
  3. functions

maci.xmldumpstr

dumps element data to a string as xml

Last updated 1 year ago

dumping a string

Dumps object data to a string formatted as XML.

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

xml_string = maci.xmldumpstr(data)

In this example, we simply dump data to a string using the xmldumpstr function and pass data as an argument to the function, and assign the returned data to a variable.

To learn more about building out your xml ElementTree data in code, see More information on using Element 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 file from xml etree ElementTree or 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

data: Element

First and only required positional argument. Accepts objects

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

encoding: str

Optional parameter. Accepts strings. Default = 'utf-8'

Use this parameter to dump the data with the desired codec of the data if needed. The default uses a common industry standard, 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.

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
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.xmldump
maci.xmlbuildmanual
maci._defuse_xml_stdlib
Element
https://docs.python.org/3/library/xml.etree.elementtree.html
_defuse_xml_stdlib