GALAXY OF TOOLS

DEV SECTOR

XML Viewer

Open XML as a collapsible tree, search it, run XPath 1.0 queries and copy the path of any node.

Runs entirely in your browser. Nothing you enter or upload is sent to a server.

An XML viewer for exploring structure, not just reading text

The XML Viewer opens an XML document as a collapsible tree. Elements show their attributes inline, short text sits on the same line as its tag, and namespaces, CDATA sections, comments, processing instructions and the DOCTYPE each get their own colour, so the shape of a SOAP response, an RSS feed, a sitemap or a configuration file is clear at a glance.

Beyond browsing, you can search names, attributes and text, run XPath 1.0 queries with namespace prefixes and see every match highlighted in the tree, and click any node to get an XPath that selects exactly that node. Large files of several megabytes open quickly because only the branches you expand are drawn.

The file is parsed by your browser’s own XML parser and never uploaded.

How to use the XML Viewer

  1. Paste XML into XML source, drop a file on it, or press Open file. Files above about 1.5 MB are kept out of the editor so the page stays fast.
  2. Press View tree (small inputs update as you type). If the XML is not well-formed, the line, column and surrounding lines are shown.
  3. Click the arrows to open branches, or use Expand to level, Expand all and Collapse. Very long child lists appear in batches of 200.
  4. Type in the search box to find element names, attribute names or values and text; step through matches with the arrow buttons or Enter.
  5. Enter an XPath expression or pick one from Examples, then press Run XPath. Numbers, strings and booleans are shown directly; node sets are listed and highlighted.
  6. Click any node to see its path, namespace and content, then Copy path or Use as XPath.

XML Viewer features

Lazy tree for big files

Only expanded branches are rendered, 200 children at a time, so a 3 MB file with 60,000 elements opens in well under a second on a typical laptop.

Every node type

Elements, attributes, namespace declarations, text, CDATA, comments, processing instructions and the DOCTYPE are all shown, with whitespace-only text hidden unless you ask for it.

XPath 1.0 with namespaces

Queries run on the browser’s built-in document.evaluate. Prefixes declared in the file work as written, and a default namespace is mapped to d: automatically.

Click a node, get its path

Paths use positions only where needed, such as /bookstore/book[2]/title, and evaluating one selects exactly that node again.

Search with navigation

Matches in names, attribute values, text and comments are counted, and each one is revealed by opening its ancestors.

Line-numbered errors

Not-well-formed XML is reported with the parser’s message, line, column and a caret, plus a button that jumps there.

XPath examples on the sample catalogue

Load Sample and try these; the results below are what the viewer shows.

XPathResult
count(//book)number 4
sum(//book/price)number 149.93
//book[price > 35]/title2 nodes: XQuery Kick Start, Learning XML
//book[@category='web']/title2 nodes
//media:thumbnail/@url2 attribute nodes
string(//book[@lang='fr']/title)string "Learning XML"
//title[contains(., 'XML')]1 node: Learning XML
/processing-instruction()the xml-stylesheet instruction (the XML declaration is not a node)

Namespaces and XPath 1.0

In XPath 1.0 an unprefixed name always means “no namespace”. If a document declares a default namespace, as Atom feeds (xmlns="http://www.w3.org/2005/Atom"), SVG and many SOAP messages do, //entry finds nothing even though the tag is plainly there. The viewer maps the default namespace to the prefix d, so you write //d:entry; the hint under the query box shows the mapping and every prefix declared in the file.

Alternatively, ignore namespaces with //*[local-name()='entry']. Functions from XPath 2.0 and later, such as matches() or lower-case(), are not available in browsers; contains(), starts-with(), translate() and normalize-space() are.

Reading the tree

  • <price currency="USD">30.00</price> on one line means the element holds only short text.
  • A grey count such as “5 elements” marks a branch you can open.
  • Grey attributes are namespace declarations (xmlns and xmlns:prefix).
  • Text inside CDATA is shown between <![CDATA[ and ]]> exactly as written, without entity decoding.
  • With “Show whitespace-only text” ticked, indentation between tags appears as text nodes, with ↵ for line breaks — useful when text() positions surprise you.

XML Viewer FAQ

How do I view an XML file as a tree?

Open or paste the file and press View tree. This XML viewer shows the root element expanded and every other branch collapsed; click arrows to open them or choose a level from Expand to level.

Why does my XPath return nothing?

The most common reasons are a default namespace (use the d: prefix or local-name()), different capitalisation — XML names are case-sensitive — or a path that starts at the wrong level. Click the node you want and use its path as a starting point.

Can it open large XML files?

Yes. Files of tens of megabytes can be parsed, limited by your device’s memory. Only the visible branches are drawn and long lists come in batches, so expanding stays quick.

Which XPath version is supported?

XPath 1.0, the version built into all major browsers. It covers axes, predicates, positions, string and number functions, count() and sum(), but not XPath 2.0 features such as regular expressions or sequences.

How is this different from the XML Formatter?

The XML Formatter rewrites the text with indentation or minifies it. The viewer leaves the text alone and lets you navigate, search and query the structure. To turn XML into data, use XML to JSON.

Is my XML uploaded?

No. Parsing, searching and XPath evaluation all run in your browser, and nothing is stored or sent anywhere.

You might also need