# maci.xmldumpdict

### dumping a file

Dumps a dictionary to a file formatted as XML. Nothing is returned. Creates a new or overwrites an existing file by default (See [append parameter](https://docs.macilib.org/docs/xml/functions/maci.xmldumpdict#append-bool) to change mode).

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

```python
maci.xmldumpdict('mydata.xml', data)
```

In this example, we simply dump data to a file using the xmldumpdict function and pass a string of the filepath to the file as the first argument to the function, then pass the dictionary data as the second argument to the function.&#x20;

### partner functions

Functions that are related for xml as dict

[maci.xmlloaddict](/docs/xml/functions/maci.xmlloaddict.md)  ->  Loads xml data from a file as dict\
[maci.xmlloadstrdict](/docs/xml/functions/maci.xmlloadstrdict.md)  ->  Loads xml data from a string as dict\
[maci.xmldumpstrdict](/docs/xml/functions/maci.xmldumpstrdict.md)  ->  Dumps xml data to a string from dict

### parameters & arguments

Describes all parameter functionality and accepted data types

<details>

<summary>filename:  str | Path</summary>

First required positional argument. Accepts strings and [Path objects](https://docs.python.org/3/library/pathlib.html)

Use this parameter to point to your filepath

</details>

<details>

<summary>data:  dict[str, Any]</summary>

Second required positional argument. Accepts dictionaries

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

</details>

<details>

<summary>append:  bool</summary>

Optional parameter. Accepts booleans. Default = False

Use this parameter to enable appending mode to write by appending data to the file. A new file will be created if the filename does not exist. Default is disabled which writes new or overwrites a file.

</details>

<details>

<summary>pretty:  bool</summary>

Optional parameter. Accepts booleans. Default = True

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</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>

*This function uses the xmltodict library installed as a dependency from pypi for its underlying functionality. For more information on xmltodict, visit:* [*https://pypi.org/project/xmltodict/*](https://pypi.org/project/xmltodict/)

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.macilib.org/docs/xml/functions/maci.xmldumpdict.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
