XML Editor online

Code

    Export

    My documents

    Click a document to open it. They are stored only in this browser - nothing is uploaded. Clearing the browser's site data removes them, so download the ones you want to keep.

    AI Assistant

    Any AI can write with you - ChatGPT, Claude, Gemini, Copilot.

    1. Click Copy prompt.
    2. Paste it into your AI and say what it should write.
    The AI should

    The document travels in the link after the “#”, which no server sees. What you paste into your AI is handled by its provider.

    Save to your server

    The editor can send each saved version to your own server (a webhook), so your work is kept where you want it. Nothing is sent until you enter an address here.

    What your server receives

    A POST request with JSON (your server must allow CORS from https://xml.giit.ch):

    { "editor": "xml", "event": "save", "id": "…", "name": "Catalog",
      "content": "<?xml version=\"1.0\"?> …",
      "updated": "2026-01-15T09:30:00.000Z" }
    Embed the editor in your website
    <iframe src="https://xml.giit.ch/?embed=1" style="width:100%;height:80vh;border:0"></iframe>
    <script>
    const frame = document.querySelector('iframe');
    addEventListener('message', e => {
      if (e.origin !== 'https://xml.giit.ch' || e.source !== frame.contentWindow) return;
      if (e.data.type === 'xmleditor:ready')
        frame.contentWindow.postMessage({ type: 'xmleditor:load', name: 'Catalog',
          content: '<catalog>…</catalog>' }, 'https://xml.giit.ch');
      if (e.data.type === 'xmleditor:save') saveOnYourServer(e.data.content);
    });
    </script>

    Also possible: ?src=<URL of an XML file> opens a file, &webhook=<URL> saves this document there. The editor can also open in a window of its own (?embed=window), and your page can hand it its own AI prompt and a session key so the AI sends its result to your server (xmleditor:ai, xmleditor:key-request) - see "Use the editor on your own website" below the editor. Details are in llms.txt.

    Help

    How it works

    1. Write XML on the left - or start with New and one of the templates. The tree in the middle shows the elements, attributes, text, comments and CDATA as you type.
    2. Click a node in the tree to go to its place in the code; the cursor in the code shows its node in the tree. Fold elements with the arrow.
    3. Click a name, an attribute value or a text in the tree to edit it right there. Enter or a click elsewhere writes the change into the code (special characters escaped, one step for Undo), Escape cancels. The buttons of a row add a child element or an attribute, move the element up or down, or remove it.
    4. Search marks nodes whose name, value or text contains the words; the XPath field marks the nodes an XPath 1.0 expression selects (_: is the default namespace of the root).
    5. Problems (the first well-formedness error, undeclared namespace prefixes, ids used twice) are listed above the code with line and column - click one to go there.
    6. Node on the right shows the selected node; Insert has ready-made pieces; Convert formats, minifies and turns the document into JSON or YAML.
    7. My documents (the folder button at the top left) lists every document kept in this browser. Export saves XML, minified XML, JSON, YAML or plain text.

    The editor never loads a DTD, a schema or an external entity, and it does not expand entities declared in a DTD: their references stay as written.

    Keyboard shortcuts

    > after a start tag
    Adds the matching end tag
    Ctrl + /
    Comment lines in or out (<!-- -->)
    Ctrl + Enter
    Show the cursor's node in the tree
    Tab / Shift + Tab
    Indent / outdent
    Ctrl + Z / Y
    Undo / redo
    Ctrl + S / E
    Save (download .xml, or to your server) / export
    Ctrl + O
    My documents
    Ctrl + F
    Search in the tree (outside the code)

    Modifica XML online, con un albero dal vivo

    L'Editor XML mostra il tuo codice e il suo albero degli elementi uno accanto all'altro. Tutto ciò che scrivi appare subito nell'albero - elementi, attributi, testo, commenti, CDATA e namespace - e un clic su qualsiasi nodo ti porta al suo punto nel codice. Puoi anche modificare nomi, valori e testo direttamente nell'albero, eseguire query XPath e convertire il documento in JSON o YAML.

    Tutto funziona nel tuo browser. I documenti non vengono caricati, non serve registrarsi e non c'è pubblicità.

    Cosa sa fare l'editor

    Codice evidenziato

    Tag, attributi, valori, entità, commenti e CDATA nei loro colori, numeri di riga, tag di chiusura automatici e un elenco chiaro dei problemi con riga e colonna.

    L'albero degli elementi

    Comprimi ed espandi gli elementi, vedi attributi, testo, commenti, istruzioni di elaborazione e namespace, e segui il percorso del nodo selezionato.

    Modifica nell'albero

    Rinomina elementi e attributi, cambia valori e testo, aggiungi, sposta e rimuovi elementi - scritti nel codice come piccole modifiche, con i caratteri speciali protetti.

    XPath e ricerca

    Un campo XPath 1.0 evidenzia i nodi corrispondenti; la ricerca trova nomi, valori e testo. I prefissi di namespace del documento funzionano in XPath.

    Sicuro con qualsiasi file

    Non viene mai caricata alcuna DTD, schema o entità esterna e nessuna entità viene espansa, quindi XXE e bombe di entità non funzionano.

    Formatta e converti

    Indenta o minimizza il documento, o trasformalo in JSON o YAML: attributi come @name, testo come #text, elementi ripetuti come liste.

    Come funziona

    1. Inizia - scegli un modello in «Nuovo», apri un file .xml o incolla codice XML.
    2. Modifica - scrivi nel codice o fai clic sui valori nell'albero; i problemi sopra il codice ti dicono cosa non è ben formato.
    3. Esporta - salva l'XML, una copia minimizzata, JSON, YAML o il testo semplice.

    Usare l'editor sul tuo sito web

    Qualsiasi pagina https (e localhost) può integrare l'editor con un <iframe> e ?embed=1 - senza registrazione, senza chiave. Integrato, l'editor nasconde questo testo e mostra un pulsante Salva. Ci sono due modi per far entrare e uscire il documento.

    1. Aprire un file da un link, salvare sul tuo server

    src= apre un file (il tuo server deve consentire CORS), webhook= fa sì che «Salva» (Ctrl+S) invii il documento a quell'indirizzo. Aggiungi &token=… per un'intestazione Authorization: Bearer … e &auto per salvare dopo ogni modifica.

    <iframe src="https://xml.giit.ch/?embed=1&src=https://your-site.com/data/catalog.xml&webhook=https://your-site.com/save.php"
            allow="clipboard-write" style="width:100%;height:800px;border:0"></iframe>

    Il webhook riceve un POST con JSON { editor: "xml", event: "save", id, name, content, updated }. Un piccolo script PHP che lo salva:

    <?php
    header('Access-Control-Allow-Origin: https://xml.giit.ch');
    header('Access-Control-Allow-Headers: Content-Type, Authorization');
    header('Access-Control-Allow-Methods: POST, OPTIONS');
    if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') exit;
    if (($_SERVER['HTTP_AUTHORIZATION'] ?? '') !== 'Bearer SECRET') { http_response_code(403); exit; }
    $d = json_decode(file_get_contents('php://input'), true);
    $name = preg_replace('/[^\w\- ]/u', '_', $d['name']);
    file_put_contents(__DIR__ . "/data/$name.xml", $d['content']);
    echo '{"ok":true}';

    2. La tua pagina custodisce il documento (postMessage)

    L'editor dice xmleditor:ready, la tua pagina risponde con xmleditor:load, l'editor segnala xmleditor:loaded, xmleditor:change alle modifiche reali e xmleditor:save quando l'utente salva. La tua pagina può inviare xmleditor:get (lo stato attuale) o xmleditor:save (premi Salva). Il salvataggio passa così dal tuo login e dalla tua sessione.

    <iframe id="ed" src="https://xml.giit.ch/?embed=1" allow="clipboard-write" style="width:100%;height:800px;border:0"></iframe>
    <script>
    const ed = document.getElementById('ed');
    const ORIGIN = 'https://xml.giit.ch';
    
    addEventListener('message', async e => {
      if (e.source !== ed.contentWindow || e.origin !== ORIGIN) return;
      const m = e.data;
      if (m.type === 'xmleditor:ready') {               // l'editor è pronto: passagli il documento
        ed.contentWindow.postMessage({
          type: 'xmleditor:load',
          name: 'Catalog',
          content: await (await fetch('/data/catalog.xml')).text()
        }, ORIGIN);
      }
      if (m.type === 'xmleditor:change') document.title = '● not saved';     // una modifica reale
      if (m.type === 'xmleditor:save') {                // l'utente ha fatto clic su "Salva"
        await fetch('/api/save', { method: 'POST', headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ name: m.name, content: m.content }) });
        document.title = 'Saved';
      }
    });
    
    // Un pulsante Salva sulla tua pagina: la risposta arriva come xmleditor:save
    function saveNow() { ed.contentWindow.postMessage({ type: 'xmleditor:get' }, ORIGIN); }
    </script>

    Assistente IA nella tua pagina: funziona anche nel riquadro. Con allow="clipboard-write" sull'iframe, «Copia il prompt» usa direttamente gli appunti (altrimenti l'editor ricorre al vecchio comando di copia, o mostra il prompt da copiare a mano). Un link inviato dall'IA non può raggiungere un editor dentro un altro sito web, quindi l'editor dice all'IA e all'utente di incollare invece l'intera risposta dell'IA nell'editor - oppure di aprire l'editor in una finestra propria.

    3. In una finestra propria

    window.open("https://xml.giit.ch/?embed=window", "xmleditor-17") apre l'editor completo in una finestra propria e usa gli stessi messaggi con window.opener. Lì lo raggiungono i link di un'IA. xmleditor:load può portare anche context: { host, title, rules } - il prompt per l'IA dice allora a chi appartiene il documento e segue le tue regole - e hook: { url, token }, un webhook solo per questo documento che non viene mai salvato. Chiudere la finestra con modifiche non salvate invia xmleditor:closing.

    4. IA tramite il tuo server

    Passa all'editor il tuo prompt, un indirizzo sul tuo sito e una chiave per questa sessione dell'editor. La finestra dell'IA mostra allora «Connesso a» il tuo sito, ciò che dici all'IA e la scelta modificare il documento attuale o crearne uno nuovo; Copia il prompt mette tutto insieme. L'IA invia il risultato con la chiave al tuo server, e la tua pagina lo apre nell'editor - un nuovo documento si apre separatamente e resta nel browser dell'utente. Una chiave per sessione dell'editor: resta valida finché l'editor è aperto, e solo finché non ne ha una l'editor la chiede con xmleditor:key-request. L'editor non invia mai la chiave di sua iniziativa e non la salva mai; l'indirizzo deve essere https sul tuo host o su un suo sottodominio.

    const key = async () => (await fetch('/api/ai-key.php?doc=17')).json();   // una chiave per sessione dell'editor
    const k = await key();
    ed.contentWindow.postMessage({ type: 'xmleditor:load', name: 'Catalog', content, ai: {
      label: 'My Site', prompt: 'Keep the sku attributes. Prices in CHF.',
      endpoint: 'https://your-site.com/api/ai-result.php', key: k.key } }, ORIGIN);
    // ricorda l'id da xmleditor:loaded e ignora change/save/closing con un altro id
    // solo finché l'editor non ha una chiave:
    if (m.type === 'xmleditor:key-request') { const k = await key(); ed.contentWindow.postMessage({ type: 'xmleditor:ai', key: k.key }, ORIGIN); }
    // finché l'editor è aperto, avvisa il tuo server ogni minuto; chiudere l'editor o la pagina annulla la chiave
    setInterval(() => fetch('/api/ai-key.php?alive=' + k.key.slice(0, 8)), 60000);
    // il tuo server ha un risultato (polling, SSE …): target è "current" o "new"
    ed.contentWindow.postMessage({ type: 'xmleditor:load', name: 'Catalog', content: draft, from: 'ai', target }, ORIGIN);

    Crea chiavi con almeno 128 bit casuali, salvane solo l'hash, lega ciascuna all'utente connesso, al documento e a questa sessione dell'editor, creane una per sessione, mantienila valida solo finché la tua pagina segnala la sessione come aperta, e annullala quando l'editor o la pagina si chiude.

    L'intero protocollo è in llms.txt - dallo a un'IA e costruirà il collegamento per il tuo sistema. L'Editor LaTeX e l'Editor SVG funzionano allo stesso modo con i prefissi latexeditor: e svgeditor:.

    Domande frequenti

    Il mio XML viene caricato?

    No. L'editor funziona interamente nel tuo browser. I tuoi documenti non vengono mai inviati a un server, a meno che tu stesso non configuri un webhook verso il tuo server.

    L'editor verifica il mio XML?

    Sì. Usa il parser XML del browser e mostra il primo errore di buona formazione con riga e colonna, più i prefissi di namespace non dichiarati e gli id usati due volte. Non convalida rispetto a una DTD o a un XML Schema.

    È sicuro aprire XML con una DTD o entità esterne?

    Sì. L'editor non carica mai una DTD, uno schema o un'entità esterna e non espande mai le entità di una DTD, quindi gli attacchi XXE e di espansione delle entità non funzionano. I riferimenti a tali entità restano nel testo come sono scritti.

    Come uso XPath?

    Scrivi un'espressione XPath 1.0 sopra l'albero, ad esempio //book[price > 30]/title. I nodi corrispondenti vengono evidenziati nell'albero; le frecce passano dall'uno al successivo. I prefissi dichiarati nel documento funzionano, e _: indica il namespace predefinito dell'elemento radice.

    Posso convertire XML in JSON o YAML?

    Sì. In Converti o Esporta il documento diventa JSON o YAML: attributi come @name, testo come #text, elementi ripetuti come liste.

    Dove vengono salvati i miei documenti?

    Solo nel tuo browser. Fai clic sul pulsante a forma di cartella in alto a sinistra (I miei documenti) per aprirli, rinominarli, duplicarli, scaricarli o eliminarli. Cancellando i dati del sito nel browser spariscono, quindi scarica quelli che vuoi conservare - oppure lascia che l'editor li invii al tuo server («Salva sul server»).

    Un'IA può scrivere nell'Editor XML?

    Sì, qualsiasi IA - ChatGPT, Claude, Gemini, Copilot o l'IA del tuo strumento di programmazione. Fai clic su «Assistente IA», poi su «Copia il prompt», incollalo nella tua IA e dille cosa deve scrivere. L'IA risponde con un link; fai clic su di esso e il documento appare nel tuo editor. «Annulla» ritira ogni modifica.

    Posso usare l'editor sul mio sito web?

    Sì. Integralo con un iframe e scambia documenti con postMessage, oppure lascia che invii ogni versione salvata al tuo server con un webhook. Trovi esempi in Usare l'editor sul tuo sito web.

    L'Editor XML costa qualcosa?

    No. L'editor è gratuito, senza pubblicità e senza registrazione.