← XML
XML·Guide
All tools

XML

Text XML in apps: layouts and config files under assets/, Cordova's config.xml, storyboards and XIBs, SVG, XLIFF, plists. The tool checks well-formedness with the browser's own parser, shows a tree, finds elements by name, attribute or text, and formats or minifies. Android's binary XML (AndroidManifest.xml and res/ in an APK) opens in the AXML tool instead, and binary plists in the Plist tool.

1The XML library

lib/xml.js is a JavaScript module with no dependencies and no user interface. It exports XmlText, a class of static methods. It uses DOMParser, so it works in pages, not workers.

<script type="module">
	import { XmlText } from "../lib/xml.js";

	const documentNode = XmlText.parse(text);                 // throws with error.line and error.column
	const formatted = XmlText.serialize(documentNode, 2, XmlText.declarationOf(text));
	const permissions = XmlText.find(documentNode, "permission", 100);
</script>
MethodWhat it does
XmlText.parse(text)A Document; errors carry line and column when the engine reports them.
XmlText.serialize(document, indent, declaration)XML text: indented by indent spaces, or minified with 0; blank text is dropped, comments, CDATA and the doctype kept.
XmlText.declarationOf(text)The <?xml …?> declaration, or null.
XmlText.decode(bytes){ text } using the byte order mark, or { binary: "axml" | "bplist" }.
XmlText.find(document, query, limit)Elements whose name, attributes, text or comments contain query.
XmlText.shownChildren(node), XmlText.inlineText(element)The children worth showing (no blank text); the text of a text-only element.
XmlText.NODEThe node type numbers: { element, text, cdata, processingInstruction, comment, doctype }.