xmltext

A FAPI element using a textarea with xml validation.

<?php
$form['xml_config'] = array(
  '#type' => 'xmltext',
  '#title' => 'XML config',
  '#default_value' => variable_get('xml_config', ''),
  '#xml_schema' => '<xs:schema>...</xs:schema>',
  '#xml_example' => '<something>...</something>',
);

xml_codemirror

Enable xml_field_codemirror module to introduce this FAPI element, which creates a CodeMirror input field with xml validation.

Refer to the online API for more info.

You may alter the global default options using hook_xml_field_codemirror_config_alter(). For fields you may alter some configuration options in the field UI. To control the CodeMirror options at the element level add/alter the key #codemirror_options:

<?php
$form['xml_config'] = array(
  '#type' => 'xml_codemirror',
  '#title' => 'XML config',
  '#default_value' => variable_get('xml_config', ''),
  '#codemirror_options' => array(
    'tabSize' => 2, 
  );
);