> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/xml/xmlparse.md).

# XMLParse

Return new array

## Method Signature

```
XMLParse(XML=[string], caseSensitive=[boolean], validator=[any], lenient=[boolean])
```

### Arguments

| Argument        | Type      | Required | Description                                                                                                                 | Default |
| --------------- | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------- | ------- |
| `XML`           | `string`  | `false`  | The XML string (or a file/URL containing XML) to parse                                                                      |         |
| `caseSensitive` | `boolean` | `false`  | Whether element/attribute name matching is case-sensitive                                                                   | `true`  |
| `validator`     | `any`     | `false`  | Either a path/URL to an XSD schema to validate against, **or** (as of 1.17.0) a struct of XML security settings — see below |         |
| `lenient`       | `boolean` | `false`  | As of 1.17.0: overrides `lenientProcessing` in the effective XML security settings when explicitly passed                   |         |

## XML Security (1.17.0+)

By default, `xmlParse()` uses your application's `xml` config settings (see [XML Security Settings](/getting-started/configuration/directives.md#xml-security-settings)) to guard against XXE (XML External Entity) attacks when parsing untrusted XML. Pass a struct as `validator` to override those defaults for a single call:

```java
xmlDoc = xmlParse(
	xml = untrustedXmlString,
	validator = {
		secureProcessing            : true,
		disallowDoctypeDeclaration  : true,
		allowExternalEntities       : false,
		lenientProcessing           : false
	}
)
```

`validator` still accepts the original XSD path/URL string for schema validation — passing a struct instead switches it to security-settings mode; the two uses are mutually exclusive per call.

## Examples

### Parse XML read from a file

Read XML from a file and use the xmlParse method to parse it into an XML data structure.

```java
<bx:file action="read" file="#tempxml#" variable="xmlString">
<bx:set myXML = xmlParse( xmlString ) >
```

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxFjrEOwiAURXe%2B4qVTu8gHFEl0cjRObobKtSXhFQWatH9vgyG%2B6byTO5yV%2FSPlCMN0pEbQfmoOGbrg%2FuSgT949oeROVb5iYH0Og5KFqp5grJtHfQO72SIqWU1dDMFu%2BoIIconyBGKkZEbQFhaK%2BCxIGfagZBn%2BcmTtaXphF363dGd%2FNTGhpfWf31HXiy%2FEgj49)

```java
xml_stream = "
    <note>
      <to>Alice</to>
      <from>Bob</from>
      <heading>Reminder</heading>
      <body>Here is the message you requested.</body>
    </note>
  ";
dump( XmlParse( xml_stream ) );

```

## Related

* [XMLChildPos](/boxlang-language/reference/built-in-functions/xml/xmlchildpos.md)
* [XMLElemNew](/boxlang-language/reference/built-in-functions/xml/xmlelemnew.md)
* [XMLFormat](/boxlang-language/reference/built-in-functions/xml/xmlformat.md)
* [XMLGetNodeType](/boxlang-language/reference/built-in-functions/xml/xmlgetnodetype.md)
* [XMLNew](/boxlang-language/reference/built-in-functions/xml/xmlnew.md)
* [XMLSearch](/boxlang-language/reference/built-in-functions/xml/xmlsearch.md)
* [XMLTransform](/boxlang-language/reference/built-in-functions/xml/xmltransform.md)
* [XMLValidate](/boxlang-language/reference/built-in-functions/xml/xmlvalidate.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/xml/xmlparse.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
