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)

    ライブツリーで XML をオンライン編集

    XML エディターは、コードとその要素ツリーを並べて表示します。入力した内容 (要素、属性、テキスト、コメント、CDATA、名前空間) はすぐにツリーに反映され、ノードをクリックするとコード内のその位置へ移動します。ツリーで直接名前、値、テキストを編集し、XPath クエリを実行して、ドキュメントを JSON や YAML に変換することもできます。

    すべてブラウザー内で動作します。ドキュメントはアップロードされず、登録も広告もありません。

    エディターでできること

    ハイライト付きのコード

    タグ、属性、値、実体参照、コメント、CDATA を色分けし、行番号、自動で閉じる終了タグ、行と列付きのわかりやすい問題一覧を備えています。

    要素ツリー

    要素の折りたたみと展開、属性、テキスト、コメント、処理命令、名前空間の表示、選択したノードのパスの表示。

    ツリーで編集

    要素と属性の名前変更、値とテキストの変更、要素の追加、移動、削除。特殊文字をエスケープして、小さな編集としてコードに書き込まれます。

    XPath と検索

    XPath 1.0 欄で一致するノードに印を付け、検索で名前、値、テキストを探します。ドキュメントの名前空間接頭辞は XPath でも使えます。

    どんなファイルでも安全

    DTD、スキーマ、外部実体を読み込むことはなく、実体も展開しないため、XXE や実体爆弾 (entity bomb) は機能しません。

    整形と変換

    ドキュメントをインデントまたは圧縮し、JSON や YAML に変換します: 属性は @name、テキストは #text、繰り返す要素はリストになります。

    使い方

    1. 始める - 「新規」でテンプレートを選ぶか、.xml ファイルを開くか、XML コードを貼り付けます。
    2. 編集 - コードを入力するか、ツリーの値をクリックします。コードの上の問題一覧が、整形式でない箇所を教えてくれます。
    3. エクスポート - XML、圧縮したコピー、JSON、YAML、プレーンテキストを保存します。

    エディターを自分の Web サイトで使う

    https のページ (および localhost) なら、<iframe> と ?embed=1 でエディターを埋め込めます。登録もキーも不要です。埋め込まれたエディターはこの説明文を隠し、保存ボタンを表示します。ドキュメントを受け渡す方法は 2 つあります。

    1. リンクからファイルを開き、自分のサーバーに保存する

    src= でファイルを開き (サーバーで CORS の許可が必要)、webhook= を指定すると「保存」(Ctrl+S) でドキュメントがそのアドレスに送信されます。&token=… を付けると Authorization: Bearer … ヘッダーが付き、&auto を付けると変更のたびに保存します。

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

    Webhook は JSON { editor: "xml", event: "save", id, name, content, updated } を含む POST を受け取ります。それを保存する小さな PHP スクリプト:

    <?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. ページがドキュメントを保持する (postMessage)

    エディターが xmleditor:ready を送り、ページが xmleditor:load で応答すると、エディターは xmleditor:loaded を返し、実際に編集されると xmleditor:change、ユーザーが保存すると xmleditor:save を送ります。ページからは xmleditor:get (現在の状態) や xmleditor:save (保存ボタンを押す) を送れます。保存はあなた自身のログインとセッションを通して行われます。

    <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') {               // エディターの準備完了: ドキュメントを渡す
        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';     // 実際の編集
      if (m.type === 'xmleditor:save') {                // ユーザーが「保存」をクリックした
        await fetch('/api/save', { method: 'POST', headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ name: m.name, content: m.content }) });
        document.title = 'Saved';
      }
    });
    
    // 自分のページの保存ボタン: 応答は xmleditor:save として届く
    function saveNow() { ed.contentWindow.postMessage({ type: 'xmleditor:get' }, ORIGIN); }
    </script>

    ページ内の AI アシスタント: フレーム内でも動作します。iframe に allow="clipboard-write" を付けると、「プロンプトをコピー」がクリップボードを直接使います (付けない場合は古いコピーコマンドを使うか、手動でコピーできるようプロンプトを表示します)。AI が送るリンクはほかの Web サイト内のエディターには届かないため、エディターは AI とユーザーに、代わりに AI の回答全体をエディターに貼り付けるよう案内します。または、エディターを専用のウィンドウで開いてください。

    3. 専用のウィンドウで開く

    window.open("https://xml.giit.ch/?embed=window", "xmleditor-17") は完全なエディターを専用のウィンドウで開き、window.opener と同じメッセージをやり取りします。AI からのリンクもそこに届きます。xmleditor:load には context: { host, title, rules } (AI プロンプトがドキュメントの所属先を伝え、あなたのルールに従います) と hook: { url, token } (このドキュメント専用で保存されない Webhook) も含められます。未保存の変更があるままウィンドウを閉じると xmleditor:closing が送られます。

    4. 自分のサーバー経由の AI

    エディターに独自のプロンプト、サイト上のアドレス、このエディターセッション用のキーを渡します。すると AI ダイアログには、あなたのサイトへの「接続先」、AI に伝える内容、そして 現在のドキュメントを変更 か 新しいドキュメントを作成 の選択肢が表示され、プロンプトをコピー ですべてがまとめられます。AI はキーを付けて結果をあなたのサーバーに送り、ページがそれをエディターで開きます。新しいドキュメントは別に開き、ユーザーのブラウザー内に残ります。キーはエディターセッションごとに 1 つです。エディターを開いている間は有効で、キーがないときだけエディターが xmleditor:key-request で要求します。エディターがキーを自分で送ったり保存したりすることはありません。アドレスはあなた自身のホストまたはそのサブドメイン上の https である必要があります。

    const key = async () => (await fetch('/api/ai-key.php?doc=17')).json();   // エディターセッションごとにキーを 1 つ
    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);
    // xmleditor:loaded の id を覚えておき、別の id の change/save/closing は無視する
    // エディターにキーがないときだけ:
    if (m.type === 'xmleditor:key-request') { const k = await key(); ed.contentWindow.postMessage({ type: 'xmleditor:ai', key: k.key }, ORIGIN); }
    // エディターを開いている間、毎分サーバーに知らせる。エディターまたはページを閉じるとキーは無効になる
    setInterval(() => fetch('/api/ai-key.php?alive=' + k.key.slice(0, 8)), 60000);
    // サーバーに結果がある (ポーリング、SSE …): target は "current" または "new"
    ed.contentWindow.postMessage({ type: 'xmleditor:load', name: 'Catalog', content: draft, from: 'ai', target }, ORIGIN);

    キーは 128 ビット以上のランダム値で作り、ハッシュだけを保存し、それぞれをログイン中のユーザー、ドキュメント、このエディターセッションに結び付けてください。キーはセッションごとに 1 つ作り、ページがセッションを開いていると報告している間だけ有効にし、エディターまたはページが閉じたら無効にしてください。

    プロトコルの全体は llms.txt にあります。AI に渡せば、あなたのシステム用の接続を作ってくれます。LaTeX エディターと SVG エディターも、接頭辞 latexeditor: と svgeditor: で同じように動作します。

    よくある質問

    XML はアップロードされますか?

    いいえ。エディターは完全にブラウザー内で動作します。自分で自分のサーバーへの Webhook を設定しない限り、ドキュメントがサーバーに送られることはありません。

    エディターは XML をチェックしますか?

    はい。ブラウザー自身の XML パーサーを使い、最初の整形式エラーを行と列付きで表示するほか、宣言されていない名前空間接頭辞と 2 回使われた id も示します。DTD や XML Schema による検証は行いません。

    DTD や外部実体を含む XML を開いても安全ですか?

    はい。エディターは DTD、スキーマ、外部実体を読み込むことはなく、DTD の実体を展開することもないため、XXE や実体展開攻撃は機能しません。そうした実体への参照は、書かれたままテキストに残ります。

    XPath はどうやって使いますか?

    ツリーの上に XPath 1.0 式を入力します。例: //book[price > 30]/title。一致するノードはツリーで示され、矢印で次へ移動できます。ドキュメントで宣言された接頭辞が使え、_: はルート要素の既定の名前空間を表します。

    XML を JSON や YAML に変換できますか?

    はい。変換 または エクスポート で、ドキュメントは JSON や YAML になります: 属性は @name、テキストは #text、繰り返す要素はリストになります。

    ドキュメントはどこに保存されますか?

    ブラウザー内だけです。左上のフォルダーボタン (マイドキュメント) をクリックすると、開く、名前の変更、複製、ダウンロード、削除ができます。ブラウザーのサイトデータを消去すると削除されるので、残したいものはダウンロードするか、エディターから自分のサーバーに送ってください (「サーバーに保存」)。

    AI に XML エディターで書いてもらえますか?

    はい、どの AI でも使えます。ChatGPT、Claude、Gemini、Copilot、またはコーディングツールの AI です。「AI アシスタント」、続いて「プロンプトをコピー」をクリックし、AI に貼り付けて何を書くか伝えてください。AI はリンクで回答します。クリックするとドキュメントがエディターに表示されます。「元に戻す」ですべての変更を戻せます。

    エディターを自分の Web サイトで使えますか?

    はい。iframe で埋め込んで postMessage でドキュメントをやり取りするか、Webhook で保存した版をすべて自分のサーバーに送れます。例は エディターを自分の Web サイトで使う をご覧ください。

    XML エディターは有料ですか?

    いいえ。エディターは無料で、広告も登録もありません。