# maci.xmldumpstr

### dumping a string

Dumps [Element](https://docs.python.org/3/library/xml.etree.elementtree.html) object data to a string formatted as XML.

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

```python
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.&#x20;

To learn more about building out your xml ElementTree data in code, see [xmlbuildmanual](https://docs.macilib.org/docs/xml/functions/maci.xmlbuildmanual)\
\
\
More information on using Element data:\
Youtube Video Search: <https://www.youtube.com/results?search_query=python+xml+etree>\
Documentation: <https://docs.python.org/3/library/xml.etree.elementtree.html>

### partner functions

Functions that are related for ElementTree

[maci.xmlload](https://docs.macilib.org/docs/xml/functions/maci.xmlload)  ->  Loads xml data from a file as Element or ElementTree object\
[maci.xmlloadstr](https://docs.macilib.org/docs/xml/functions/maci.xmlloadstr)  ->  Loads xml data from a string as Element object\
[maci.xmldump](https://docs.macilib.org/docs/xml/functions/maci.xmldump)  ->  Dumps xml data to a file from xml etree ElementTree or Element object\
[maci.xmlbuildmanual](https://docs.macilib.org/docs/xml/functions/maci.xmlbuildmanual)  ->  Returns empty xml ElementTree object to manually build xml data\
[maci.\_defuse\_xml\_stdlib](https://docs.macilib.org/docs/xml/functions/maci._defuse_xml_stdlib)  ->  Monkey patch and defuse all stdlib packages \[security use]

### parameters & arguments

Describes all parameter functionality and accepted data types

<details>

<summary>data:  Element</summary>

First and only required positional argument. Accepts [Element](https://docs.python.org/3/library/xml.etree.elementtree.html) objects

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

</details>

<details>

<summary>pretty: bool  <em>(Added in v1.1.1)</em></summary>

Optional parameter. Accepts booleans. Default = True

*Only available in py39+*

Use this parameter to enable automatic indentation writes on sub-elements. Disable if you want all xml data to be in one line.

</details>

<details>

<summary>full_doc: bool  <em>(Added in v1.1.1)</em></summary>

Optional parameter. Accepts booleans. Default = True

Use this parameter to enable output to be a complete xml document, which includes the xml declaration at the top. Default is enabled for formal xml document info. Disabling is useful when you only need a portion of an XML document or when you are generating xml.

</details>

<details>

<summary>encoding:  str</summary>

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.

</details>

*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:* [*https://docs.python.org/3/library/xml.etree.elementtree.html*](https://docs.python.org/3/library/xml.etree.elementtree.html)

**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.

Additionally, see the provided tooling to potentially assist with vulnerabilities [\_defuse\_xml\_stdlib](https://docs.macilib.org/docs/xml/functions/maci._defuse_xml_stdlib)
