# maci.xmlload

### loading a file

Loads xml file data, and returns an [Element](https://docs.python.org/3/library/xml.etree.elementtree.html) or [ElementTree](https://docs.python.org/3/library/xml.etree.elementtree.html#module-xml.etree.ElementTree) object.

{% hint style="info" %}
maci.xmlload  ->  [Element](https://docs.python.org/3/library/xml.etree.elementtree.html) | [ElementTree](https://docs.python.org/3/library/xml.etree.elementtree.html#module-xml.etree.ElementTree)
{% endhint %}

*Basic Example of loading a xml file using default positional parameter*

```python
data = maci.xmlload('mydata.xml')
```

In this example, we simply load xml data from a file using the xmlload function and pass a string of the filepath to the file as an argument to the function to load the xml data, and assign the returned data to a variable.

\
\&#xNAN;*Basic Example of xml data in file and accessing element data*

*file example*

```xml
<mydata>
    <data1>one</data1>
</mydata>
```

*accessing in code*

```python
data.find('data1').text
```

Note: All values in a xml file are returned as strings.

\
More information on using Element and ElementTree 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.xmlloadstr](/docs/xml/functions/maci.xmlloadstr.md)  ->  Loads xml data from a string as Element object\
[maci.xmldump](/docs/xml/functions/maci.xmldump.md)  ->  Dumps xml data to a file from xml etree ElementTree or Element object\
[maci.xmldumpstr](/docs/xml/functions/maci.xmldumpstr.md)  ->  Dumps xml data to a string from xml etree Element object\
[maci.xmlbuildmanual](/docs/xml/functions/maci.xmlbuildmanual.md)  ->  Returns empty xml ElementTree object to manually build xml data\
[maci.\_defuse\_xml\_stdlib](/docs/xml/functions/maci._defuse_xml_stdlib.md)  ->  Monkey patch and defuse all stdlib packages \[security use]

### parameters & arguments

Describes all parameter functionality and accepted data types

<details>

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

First and only 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>auto_get_root:  bool</summary>

Optional parameter. Accepts booleans. Default = True

Returns the root Element object of the ElementTree parsed from a xml file. Default is enabled to simplify data navigation steps. Disable it to get the main ElementTree object.

</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](/docs/xml/functions/maci._defuse_xml_stdlib.md)


---

# 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.xmlload.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.
