XML Parser

Format, validate, and query XML documents instantly. Powered by native browser APIs for maximum speed and privacy.

Format & Minify XPath Querying Validation

How to Use XML Parser

1

Paste Your XML

Copy and paste your XML content into the input field, or click Load Sample XML.

2

Format & Validate

Use Format to beautify, Minify to compress, or Validate to check for errors.

3

Query with XPath

Enter an XPath expression and click Run XPath to extract specific nodes.

What is XML?

XML (eXtensible Markup Language) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It is widely used for configuration files, data exchange (SOAP, RSS, Atom), and document storage.

Key XML Features

Self-descriptive

XML uses custom tags to describe data structure, making it easy to understand the content and hierarchy at a glance.

Platform Independent

As plain text, XML works across all platforms, programming languages, and systems without compatibility issues.

Extensible

You can define your own tags and document structure using DTD or XML Schema to suit any data model.

Frequently Asked Questions

What is the difference between well-formed and valid XML?

Well-formed XML follows the basic syntax rules of XML (proper nesting, closing tags, single root element). Valid XML is well-formed AND conforms to a schema (DTD, XSD) that defines the allowed structure and data types.

Does this tool validate against an XSD schema?

No, this tool checks for well-formedness only (syntax correctness). Schema-based validation against DTD or XSD is not supported in the browser natively.

What XPath version is supported?

The browser's native document.evaluate() supports XPath 1.0. This covers most common queries including axes, predicates, and functions like contains(), text(), and @attribute.

What are XML namespaces and how do they read?

A namespace maps element names to a URI via xmlns attributes - for example an atom:feed element declaring xmlns:atom="http://www.w3.org/2005/Atom". The prefix is arbitrary; only the URI identifies the namespace, so two documents can use different prefixes for the same vocabulary. Namespaces are why XPath matching often needs local-name() tricks when prefixes differ.

How does XPath select nodes?

XPath 1.0 expressions walk the tree: /rss/channel/item selects by path, //item finds items anywhere in the document, item[@type='news'] filters on an attribute, and predicates like item[1] or item[last()] pick specific nodes. It is the query language behind XSLT, many test frameworks, and this tool's evaluator.

What is XXE and could it affect this tool?

XXE (XML External Entity) injection abuses a DTD entity pointing at a file path or URL, making a server-side parser fetch it - historically leaking /etc/passwd or internal services. Browser XML parsers do not resolve external entities, and this tool runs entirely in your browser with no server round-trip, so pasted XML cannot trigger file reads or SSRF.

What is the difference between DOM and SAX parsing?

DOM loads the whole document into a tree you can navigate randomly - intuitive but memory-hungry for huge files. SAX streams events (start tag, text, end tag) in a single pass with constant memory - fast but forward-only. Browser JavaScript exposes DOMParser (DOM-style); streaming XML in JavaScript needs a library or Web Streams.

How do I include < or & inside XML content?

Escape them as &lt; and &amp; in ordinary text - < and & are illegal raw in character data. For blocks of markup-heavy text, wrap it in a CDATA section, which needs no escaping until it hits the sequence ]]> at its end. Only < and & are strictly required in content; > must be escaped only when it forms that closing sequence.

{-- * External Resources Component(#18 Phase 3b 内容佐证工程) * 工具页「权威引用」区块:RFC / W3C / WHATWG / ECMA / IANA / 官方规范站 / Wikipedia。 * * - 接受 :slug 属性 → 经 config/tool-sources.php 家族矩阵渲染该工具的权威引用 * - slug 未命中映射时不渲染(无权威来源的工具静默跳过) * - 链接 title 保持英文(引用源专名);description 经 * common.resources.descriptions.{key} 本地化,lang 未命中回退英文(线上不裸奔) * - 链接保持 dofollow(rel="noopener noreferrer") * * @param string|null $slug --}}