> For the complete documentation index, see [llms.txt](https://sevenval.gitbook.io/flat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sevenval.gitbook.io/flat/develop/reference/functions/decrypt-xml.md).

# decrypt-xml()

```
boolean decrypt-xml(encrypted_data, string private_key [, string passphrase])
```

Decrypts an `EncryptedData` XML element which was encrypted using [XML Encryption](https://www.w3.org/TR/xmlenc-core1/) and *replaces* it with its unenrypted counterpart.

* `encrypted_data`: a node-set containing the `EncryptedData` element in the `http://www.w3.org/2001/04/xmlenc#` namespace as its first node,

  or an encrypted DOM document or an XML string. Only the first node of a provided node-set will be decrypted.
* `private_key`: Private key to decrypt the symmetric encryption key provided in the `EncryptedKey` element.

  See [`decrypt()`](/flat/develop/reference/functions/decrypt.md#private-key-format) for the expected format of the private key.
* `passphrase` (optional): passphrase for decrypting an encrypted `private_key` (defaults to `""`).

Returns `true()` if `encrypted_data` was successfully decrypted, `false()` otherwise.

## Example

```markup
<flow>
  …
  <eval out="$document">xml-parse($encrypted-xml-string)</eval>

  <template>
  {{if decrypt-xml($document, $env/PRIVATE_KEY, $env/PASSPHRASE]) }}
    Decrypted ciphertext: {{ $document }}
  {{else}}
    Decryption failed!
  {{end}}
  </template>
<flow>
```


---

# 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:

```
GET https://sevenval.gitbook.io/flat/develop/reference/functions/decrypt-xml.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.
