Data & Analysis

XML Repair: Fix It, Change No Text

Repairs broken XML so a standard parser accepts it, without changing a single text node, attribute value, comment or CDATA section, and answers with the XML only, no code fence. Fixes a raw ampersand or less-than sign in text or in an attribute value, an HTML entity name such as nbsp that plain XML does not define, an attribute value without quotes, an end tag that is missing in one place only, a declaration that is not the first thing in the file, a stray byte order mark, and chat text or a fence around the document. Whitespace, indentation, attribute order, empty elements, numeric character references and CDATA stay as written. Mis-nested tags, an element that could end in two places, a document cut off in the middle, an unknown entity name, two root elements, a repeated attribute and an HTML page get a fixed one-line CANNOT REPAIR answer instead of a guess. Use when a feed, a sitemap, an SVG, a SOAP or legacy API response, an Office file part or another model returned XML that does not parse, or when asked to fix, clean up or close invalid XML.

XML Repair: Fix It, Change No Text is a tested SKILL.md that repairs broken XML so a standard parser accepts it, without changing a single text node, attribute value, comment or CDATA section, and answers with the XML only, no code fence; an agent buys it once for $0.05 over x402.

Tested 2026-10-08No code, no hidden instructionsv1.0.0 · 10.6 KB · perpetual license

Not for

Anything beyond fixing malformed XML: validating against a schema or a DTD; XSLT, XPath or conversion to JSON; guessing text that was cut off; reformatting XML that already parses; HTML pages, which are refused. With two readings (overlapping tags, two roots, an unknown entity, a repeated attribute) you get one CANNOT REPAIR line naming the place, not a guess.

Tested, honestly

Tested 2026-10-08 with a strong and a weak model.

With and without the skill

Results with and without the skill, for Sonnet and Haiku
SonnetHaiku
withwithoutwithwithout
Documents handled right (24 documents)24/2417/2424/2418/24

Same request on both sides; the bare side is scored on content, fence removed first. Read by hand, Sonnet without the skill did every plain repair and closed the two unclosed items as siblings without touching the text, which we accept. It missed the cases where the right answer is to stop: it re-nested overlapping tags, completed a cut-off title and feed, wrote the unknown entity as literal text, turned an HTML page into XHTML, wrapped two roots in an invented element and dropped one of two repeated attributes. It also rewrote the quotes and end tag of an already-valid SVG. Haiku without the skill showed the same six misses; its HTML conversion also moved elements. With the skill both models refused those seven cases with the one line and left valid files unchanged.

Same cases and the same checks with and without the skill. The cases are ours, written around what the skill is for; with a handful of cases, a difference of one or two is within noise.

SonnetStrong model, claude-sonnet-5-5
Right on all 24 documents, read by hand: it escaped a raw ampersand in text and in a link value, mapped nbsp to a numeric reference without a second escape, quoted bare attribute values, closed the one missing end tag, moved a misplaced declaration to the first byte and kept the comment, answered with bare XML instead of the fenced chat reply, left a planted comment and a sentence that talks to the AI as plain text, and returned the six already-valid files untouched. It gave the one-line CANNOT REPAIR answer for overlapping tags, a cut-off feed, an unknown entity name, an HTML page, two roots, a repeated attribute and the items with no end tags.
HaikuWeak model, claude-haiku-5-5
Right on all 24 documents by the skill's own checks, read by hand. Every repair kept the text, the whitespace and the CDATA as written, the declaration was moved and not added, and the seven risky documents (overlap, cut-off, unknown entity, HTML page, two roots, repeated attribute, items without end tags) each got the fixed refusal line instead of a repair.

Full test summary

Example

Our own test text, before and after the skill ran. Excerpts only.

English · claude-sonnet-5-5

Before

<note> <p>Say <b>hello <i>there</b> friend</i></p> </note>

After

CANNOT REPAIR: the tags b and i overlap, two ways to nest them

Bulgarian · claude-sonnet-5-5

Before

<каталог> <продукт код="007">Чай & мед — 1,250 лв.</продукт> </каталог>

After

<каталог> <продукт код="007">Чай &amp; мед — 1,250 лв.</продукт> </каталог>

What is in the file

  • What well-formed means
  • Hard rules
  • Repairs
  • When to refuse
  • Work in this order
  • Short examples

Languages

Any language. Tried in: English, Bulgarian.

License

Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing. Holder: Georgi Kalchev, aiskills402.com. Full terms.

Versions

Current version 1.0.0, updated 2026-10-08. Whoever bought an earlier version gets new ones free through the same re-download token.

  1. v1.0.0 · 2026-10-08

    First release: repairs broken XML so a standard parser accepts it, without changing any text node, attribute value, comment, processing instruction or CDATA section. Escapes raw ampersands and less-than signs (in text and in attribute values), maps undefined HTML entity names to numeric references, quotes bare attribute values, closes an element that is missing its end tag in exactly one place, moves a misplaced declaration to the first byte, drops stray characters and chat text around the document. Whitespace, empty-element form, valid entities and CDATA stay as written. Mis-nested tags, ambiguous missing end tags, cut-off documents, unknown entities, two roots, repeated attributes and HTML pages get a fixed one-line CANNOT REPAIR answer.

    Grammar facts re-checked on 2026-10-08 by a read-only fetch of the W3C Recommendation "Extensible Markup Language (XML) 1.0 (Fifth Edition)": one root and proper nesting (section 2.1), escaping of the ampersand and less-than sign and CDATA (sections 2.4 and 2.7), the element type match, unique attribute and legal character constraints (sections 3.1, 4.1), the declaration production (section 2.8), the byte order mark (section 4.3.3) and the entity declared constraint (section 4.1).

    Price to be set after the baseline run (start $0.05).

FAQ

Will it re-indent, trim or tidy the XML?

No. Whitespace inside text is data, so a node that starts and ends with spaces keeps both, indentation stays, attribute order stays, and an empty element written with an end tag is not turned into a self-closing one. Valid entities and numeric references are left as written, and a CDATA section stays a CDATA section. Only the places that break the XML 1.0 rules are touched. Comments, processing instructions and the document type line survive untouched, so a stylesheet link or a generator note is still there afterwards.

What does it do with a raw ampersand or an nbsp?

A raw ampersand in text or in an attribute value becomes the entity for an ampersand, and a raw less-than sign becomes the entity for less-than. An HTML entity name that plain XML does not define, such as nbsp or copy, is written as the numeric reference of the same character. An ampersand that already starts a valid reference is not escaped a second time, so text is never double-escaped. A name it cannot map with certainty is refused.

When does it refuse instead of repairing?

When two readings give different documents: tags that overlap, items with no end tags that could be nested or siblings, a document cut off inside a title or a value, two root elements with no wrapper named, the same attribute twice, an unknown entity name, or an HTML page. A program can detect the refusal because the whole answer is one line beginning with the words CANNOT REPAIR and a short note on where the problem sits. A cut-off element is never completed, because a finished guess is new data.

Does it help Claude Sonnet?

It does: bare Sonnet handled 17 of our 24 broken documents, and all 24 once the skill was loaded. It already knew the plain repairs (ampersands, nbsp, bare attribute values, one missing end tag, a misplaced declaration) and closed two unclosed items as siblings without touching the text. It missed the cases where the right answer is to stop: it re-nested overlapping tags, completed a cut-off feed, turned an HTML page into XHTML, wrapped two roots in an invented element and dropped one of two repeated attributes. Haiku went from 18 to 24.

Share

Read this page as Markdown: /skills/xml-repair.md.

  • JSON Repair: Fix It, Keep Every Value

    Data & Analysis

    SKILL.md · v1.0.1 · 6.9 KB

    Repairs broken JSON so a program can parse it, without changing any value. Fixes trailing and missing commas, comments, single quotes, unquoted keys, Python and JavaScript literals, smart quotes used as delimiters, raw line breaks and stray quotes inside strings, a code fence or chat text around the JSON, and output cut off in the middle. A value that was cut off becomes null instead of a guess, numbers JSON cannot hold as written are kept as strings, and when the structure can be read two ways the answer says so instead of picking one. Use when a tool, an API or another model returned JSON that does not parse, or when asked to fix, clean up, validate or close invalid or truncated JSON.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 7 Oct 2026

  • YAML Repair: Fix It, Keep Every Value

    Data & Analysis

    SKILL.md · v1.0.0 · 8.4 KB

    Repairs broken YAML and Markdown front matter so a program can parse it, without changing any value's text or type, and answers with the YAML only, no code fence. Fixes tabs used as indentation, indentation that fits no parent, a missing closing quote or bracket, values that need quotes (a colon inside, a leading star or at sign), and output cut off in the middle, where the cut value is kept as cut and never completed. Yes, no, on, off and NO stay strings, 1,250 stays a string, 1.10 and 01234 stay as written. Duplicate keys, input that is not YAML, and input with two readings get a fixed one-line answer instead of a guess. Use when a tool, an API or another model returned YAML or front matter that does not parse, or when asked to fix, clean up or close invalid or truncated YAML.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • CSV Repair: Fix the Form, Keep Every Cell

    Data & Analysis

    SKILL.md · v1.0.0 · 8.3 KB

    Repairs broken or messy CSV so a standard parser reads it, without changing the text of a single cell, and answers with the CSV only, no code fence. Fixes quotes that do not close, a quote inside an unquoted cell, cells that hold the delimiter or a line break, rows shorter than the header, a Markdown table, and chat text or a fence around the data. Numbers such as 1,250, 007 and 1.10, dates, spaces inside cells and values that look like formulas stay exactly as written. Semicolon and tab files keep their delimiter. A row longer than the header, a row that could be read two ways, an unbalanced quote that no reading closes, an HTML page and prose with no table get a fixed one-line CANNOT REPAIR answer instead of a guess that moves data between columns. Use when an export, an API or another model returned CSV that does not parse, or when asked to fix, clean up, close or convert a table to valid CSV.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026