---
title: "XMLFORMAT"
description: "La funci\u00F3n SQL XMLFORMAT da formato legible al texto XML."
language: es
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/es/docs/invantive-universalsql/grammar/sql-functions/xmlformat
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/xmlformat
updated: 2026-12-04T14:56:09Z
license: https://documentation.invantive.eu/es/
---

## Sintaxis
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> XMLFORMAT[XMLFORMAT]:::quoted
    XMLFORMAT --> End((END))
```

## Propósito
La función SQL `XMLFORMAT` formatea el texto XML de forma legible.

Véase también [[XMLCOMMENT]], [[XMLDECODE]], [[XMLELEMENT]], [[XMLENCODE]] y [[XMLTRANSFORM]].

Parámetros:
- XML (`varchar2`): código XML que se va a formatear.

Devuelve: el texto XML con formato legible.

## Ejemplos
El siguiente ejemplo formatea de forma legible un texto XML compacto:
```sql
select xmlformat('<r><name>peter</name></r>')

-------------------
<?xml version="1.0" encoding="utf-8"?>
<r>
  <name>peter</name>
</r>
```
El siguiente ejemplo genera un error, ya que el texto XML no es válido; la etiqueta de cierre `c` no coincide con la etiqueta de apertura `a`:
```sql
select xmlformat('<root><a>b</c></root>')

itgenxml120: XML formatting failed.
```

