LocalExcelTool
はじめる

XPathテスター

XML / HTML に対して XPath 式を試し、マッチ結果を即表示。

XPathテスターとは

XPathテスターは、XML や HTML に XPath 式を適用し、マッチしたノードを一覧表示するツールです。数値・文字列・真偽値の結果にも対応し、ブラウザ内蔵の XPath エンジン(document.evaluate)を使用します。パースエラーと式エラーは行レベルの情報付きで表示します。入力はどこにも送信されません。

🔒 処理はすべてブラウザ内で完結し、データは送信されません。

このツールの前提

処理場所
このページのブラウザ内(JavaScript / Canvas)
アップロード
なし — ファイルは端末の外に出ません
オフライン
ページを開いた後は通信不要

XPath 1.0, evaluated by the browser

Queries run through document.evaluate, which implements XPath 1.0. That means no XPath 2.0 or 3.1 functions — no matches(), no replace(), no for expressions, no sequences. A query copied from a schema tool or an XSLT 2.0 stylesheet will throw instead of returning results.

The context node is the parsed document, namespace handling is the standard browser one (HTML in the XHTML namespace), and the result can be a node set, a string, a number or a boolean depending on the expression. Testing an expression that returns a boolean in a node-result view shows nothing, which is not the same as failing.

HTML is not XML, and that changes the query

Browsers parse HTML leniently: unclosed tags are auto-closed, table content is reparented into tbody, and attribute names are lowercased. So //table/tr usually needs to be //table//tr, because the tr sits inside an implied tbody the source never wrote.

Class and id matching is exact and case-sensitive for values, and //div[@class="card"] fails on an element whose class is "card featured". Use contains(concat(' ', normalize-space(@class), ' '), ' card ') for a robust class test — verbose, but it is the only form that does not produce false negatives.

Where XPath still beats CSS selectors

Selecting by text content, walking to an ancestor, and indexing with positional predicates are all awkward or impossible in CSS. //button[normalize-space()='Save'] and //label[text()='Email']/following::input[1] express in one line what CSS cannot express at all.

For scraping, prefer stable structural anchors over text — labels and copy change with translations, structure changes less often. And check the expression against a second page of the same template before shipping it; an XPath that works on one product page and breaks on the next is the normal case.

使い方

  1. 1.XML/HTML を貼り付け
  2. 2.XPath 式を入力
  3. 3.実行してマッチ結果を確認

他の方法との比較

同じ変換をする方法は 3 つあります。ブラウザ内(このページ)、サーバー側の変換サービス、デスクトップアプリ。差がつくのは速度ではなく、ファイルがどこへ行くかと、無料でどこまでできるかです。

観点このツールサーバー側の変換サービス
ファイルの処理場所このページのブラウザ内ベンダーのサーバー(アップロード後)
アカウント不要多くの場合必要(無料枠の制限解除に登録を求める)
無料で扱えるサイズサイズ制限なし(回数制限もなし)数ファイル/時間、または 5〜10MB 程度で課金 wall
料金無料。Pro は月 $9(大きいファイルと AI 機能のみ)サブスクが一般的。おおむね月 $7〜15(2026 年 11 月時点)
オフライン一度開けば通信不要不可
20MB を処理し始めるまで待ち時間なし(アップロードが無い)アップロードが支配的(10Mbps 上りで約 16 秒)
保証できないこと検査は保存済みのスナップショットではなく、現在の応答に対して行います同じ(変換の原理は変わらない)

サーバー側のサービスが優れている点は明確にあります。巨大なファイル、チームでの共有、変換履歴の管理、スクリプトからの自動化。逆に「1 回だけ、手元のファイルを別形式にしたい」という今回の用途では、アップロードの待ち時間と登録の手間だけが増えます。

よくある質問

対応する結果型は?

ノード集合のほか、count() のような数値、string() のような文字列、真偽値を返す式に対応しています。

HTML も解析できる?

はい。モードを HTML に切り替えると text/html としてパースするため、class 属性での絞り込みなども可能です。

この変換で失われるもの

開発者向けツールは「静かに壊れるもの」を点検します。canonical の欠落、検索結果で切れる長さを超えた description、200 を返すが死んだ URL を載せた sitemap。各結果は該当行や URL を指します。行動できない警告は雑音だからです。

その他の開発・ネットワーク