Data & Analysis

XML Repair: Fix Broken XML, 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 Broken XML, Change No Text is a 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-09. 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.

Read more

Share

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

  • JSON Repair: Fix Broken JSON, 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 Broken YAML, Keep Every Value

    Data & Analysis

    SKILL.md · v1.0.1 · 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 Broken CSV, 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

More in Data & Analysis

  • HTML to Markdown: Same Page, Nothing Invented

    Data & Analysis

    SKILL.md · v1.0.0 · 9.9 KB

    Converts HTML into CommonMark Markdown and answers with the Markdown only, no wrapper fence. Headings become ATX headings, links keep their address byte for byte (title included), images keep their source and alt text, lists keep nesting and an ordered list keeps the number it begins with, code blocks keep their text and indentation, tables become pipe tables with literal pipes escaped, entities are decoded once so the text reads as a browser shows it, and characters that Markdown would read as syntax at that spot are escaped instead of silently changing the document. Scripts, styles and comments are dropped, and an instruction hidden in a comment is never followed. Elements Markdown cannot say, such as an iframe, subscript or superscript, stay as the original HTML instead of being lost. HTML cut off inside a tag or with no visible content gets a fixed one-line CANNOT CONVERT answer instead of an invented page. Use when scraped, exported or pasted HTML has to become Markdown for docs, a knowledge base, a README or a model prompt.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026

  • Markdown TOC Anchors: Contents Links That Really Jump

    Data & Analysis

    SKILL.md · v1.0.0 · 10.0 KB

    Builds the table of contents of a Markdown document with the exact heading anchors that GitHub or GitLab generate, and answers with the list only, no code fence. Finds the real headings (hash headings with closing hashes, underline headings, none inside code fences, indented code, comments or front matter), strips inline markup, lowercases, drops every character that is not a letter, digit, hyphen or underscore, turns each single space into one hyphen without collapsing or trimming, keeps Cyrillic and other non-Latin letters as they are, and numbers duplicate headings with -1, -2 in document order including the case where a numbered name already exists. Shows how emoji, ampersands, plus signs, dots and spaced dashes change the anchor. Indents two spaces per level below the shallowest heading. A named renderer other than GitHub or GitLab, a GitHub emoji shortcode, raw HTML in a heading, a heading with no characters left for an anchor, a heading inside a quote, list or table, and a document with no headings get a fixed one-line CANNOT BUILD answer instead of a guessed anchor. Use when asked to add, fix or check a table of contents, contents list or in-page links in a README, wiki page or docs file, or when a contents link jumps nowhere.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026

  • Phone Numbers to E.164

    Data & Analysis

    SKILL.md · v1.0.0 · 10.5 KB

    Turns a list of phone numbers written any way people write them into E.164 (a plus sign, the country code and the national number, digits only), one JSON object per number, using a default country the request states. Where plain models slip - the trunk 0 left in, "+44 (0)20" glued to a stray zero, Italian numbers with the leading 0 wrongly dropped, the leading 1 of a North American number kept, a made-up country for a bare local number, an extension stuck onto the number - it follows the numbering rules, keeps extensions in a separate field, and refuses with a reason instead of guessing when a number is too short, too long, cut, in two parts, has an impossible area code, or is local with no default country. Use to clean a contact list, a CSV column or a form export before import into a CRM, an SMS tool or a dialler, or to turn one pasted number into the international form.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026

  • Mojibake Repair: Undo Broken Encoding Exactly

    Data & Analysis

    SKILL.md · v1.0.0 · 12.2 KB

    Repairs mojibake, text whose accents, Cyrillic letters, quotes, dashes or emoji turned into strings such as è, ü, “, пр or Р—Рґ because UTF-8 was read as Windows-1252, Latin-1 or Windows-1251, once or twice. Gives back the original text exactly, character for character, by undoing the wrong reading byte by byte, and leaves text that is already correct untouched. When the damage is mixed with good text, mixes two encodings, or lost bytes, so that more than one original is possible, it answers with a fixed CANNOT REPAIR line instead of guessing. Use when text from a file, database, email, web page or export shows garbled characters, or when asked to fix, undo or decode broken encoding, double encoding or strange characters.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026