ludic/ns-xml.html
2026-09-17 22:10:03 +00:00

22 lines
No EOL
4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Xml — Ludic</title>
<meta name="description" content="A minimal, deterministic XML reader for the element/attribute/CDATA subset the native Tiled formats (TMX/TSX/TX) use.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Xml</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Xml</h1></div>
<p class="ns-blurb">A minimal, deterministic XML reader for the element/attribute/CDATA subset the native Tiled formats (TMX/TSX/TX) use. <a href="xml-parse"><code>Xml.parse</code></a> turns a document into an element tree; the accessors read a node's <a href="xml-tag"><code>tag</code></a>, <a href="xml-text"><code>text</code></a>, attributes (<a href="xml-attr"><code>Xml.attr</code></a>/<a href="xml-attr_int"><code>Xml.attr_int</code></a>/<a href="xml-has"><code>Xml.has</code></a>) and children (<a href="xml-child"><code>Xml.child</code></a>/<a href="xml-find"><code>Xml.find</code></a>/<a href="xml-count"><code>Xml.count</code></a>). It expands the five predefined entities and numeric character references, skips the <code>&lt;?xml?&gt;</code> prolog, comments and <code>&lt;!DOCTYPE&gt;</code>, and is best-effort rather than validating — the same contract as <a href="json"><code>Json</code></a>. Spliced on demand when a program mentions <code>Xml.*</code>.</p>
<div class="ns-methods"><a class="ns-method" href="xml-parse.html"><code class="nm-sig">Xml.parse(text: string) -&gt; xml</code><span class="nm-tip">Parse XML text into an element tree.</span></a><a class="ns-method" href="xml-tag.html"><code class="nm-sig">Xml.tag(node) -&gt; string</code><span class="nm-tip">The element's tag name.</span></a><a class="ns-method" href="xml-text.html"><code class="nm-sig">Xml.text(node) -&gt; string</code><span class="nm-tip">The element's character data.</span></a><a class="ns-method" href="xml-attr.html"><code class="nm-sig">Xml.attr(node, key: string) -&gt; string</code><span class="nm-tip">An attribute's value by name.</span></a><a class="ns-method" href="xml-attr_int.html"><code class="nm-sig">Xml.attr_int(node, key: string, dflt: int) -&gt; int</code><span class="nm-tip">An attribute parsed as an integer.</span></a><a class="ns-method" href="xml-has.html"><code class="nm-sig">Xml.has(node, key: string) -&gt; int</code><span class="nm-tip">Whether an attribute is present.</span></a><a class="ns-method" href="xml-attr_count.html"><code class="nm-sig">Xml.attr_count(node) -&gt; int</code><span class="nm-tip">How many attributes the element has.</span></a><a class="ns-method" href="xml-child_count.html"><code class="nm-sig">Xml.child_count(node) -&gt; int</code><span class="nm-tip">How many child elements.</span></a><a class="ns-method" href="xml-child.html"><code class="nm-sig">Xml.child(node, index: int) -&gt; xml</code><span class="nm-tip">A child element by index.</span></a><a class="ns-method" href="xml-find.html"><code class="nm-sig">Xml.find(node, tag: string) -&gt; xml</code><span class="nm-tip">The first child with a given tag.</span></a><a class="ns-method" href="xml-count.html"><code class="nm-sig">Xml.count(node, tag: string) -&gt; int</code><span class="nm-tip">How many children have a given tag.</span></a></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>