{"slug":"xml-repair","name":"XML Repair: Fix It, Change No Text","version":"1.0.0","updated_at":"2026-10-08T16:21:29.616Z","use_when":"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.","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.","languages":["any"],"tags":["xml","xml-repair","feeds","sitemaps","llm-output","no-guessing"],"category":"data","category_url":"https://aiskills402.com/categories/data","keywords":["broken XML","invalid XML","malformed XML"],"faq":[{"q":"Will it re-indent, trim or tidy the XML?","a":"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."},{"q":"What does it do with a raw ampersand or an nbsp?","a":"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."},{"q":"When does it refuse instead of repairing?","a":"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."},{"q":"Does it help Claude Sonnet?","a":"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."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"<note>\n  <p>Say <b>hello <i>there</b> friend</i></p>\n</note>","output_excerpt":"CANNOT REPAIR: the tags b and i overlap, two ways to nest them"},{"lang":"bg","model":"claude-sonnet-5-5","input_excerpt":"<каталог>\n  <продукт код=\"007\">Чай & мед — 1,250 лв.</продукт>\n</каталог>","output_excerpt":"<каталог>\n  <продукт код=\"007\">Чай &amp; мед — 1,250 лв.</продукт>\n</каталог>"}],"page_url":"https://aiskills402.com/skills/xml-repair","markdown_url":"https://aiskills402.com/skills/xml-repair.md","image_url":"https://cdn.aiskills402.com/og/skills/xml-repair/0e7388f3.png","related_url":"https://api.aiskills402.com/v1/skills/xml-repair/related","purchases_count":null,"tested":{"date":"2026-10-08","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"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."},"weak":{"model":"claude-haiku-5-5 (Claude Code alias \"haiku\")","verdict":"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."},"note":"Twenty-four documents written by us (16 traps, 8 controls): seven that must be refused, nine that need a repair, and eight controls (six already valid), with Bulgarian element names and an Atom feed with CDATA. Each answer is scored by code: a strict XML parser (errors and warnings fail), the text and attribute values compared node by node, kept comments and CDATA, no fence, and the exact CANNOT REPAIR line for refusals. Grammar facts re-checked on 2026-10-08 in the W3C XML 1.0 Recommendation (fifth edition); nothing here is an owner-measured platform fact. One check was widened after the run for both sides: for two items with no end tags, closing them as siblings with every character of text unchanged is accepted as well as the refusal (a nested reading or any changed text still fails). One run per model and document; the bare side is scored with a fence removed first.","baseline":{"date":"2026-10-08","rows":[{"label":"Documents handled right (24 documents)","better":"higher","strong":{"with":{"n":24,"of":24},"without":{"n":17,"of":24}},"weak":{"with":{"n":24,"of":24},"without":{"n":18,"of":24}}}],"note":"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."},"report_url":null},"price_usd":"0.05","price_micro":50000,"size_bytes":10884,"sha256":"8e872b4d81723333fbafc8e7c87518c4fe2bb6595fdc906d53f5bac301f318ee","outline":["What well-formed means","Hard rules","Repairs","When to refuse","Work in this order","Short examples"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/xml-repair/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0x8e37022edcf0f21cf3c9f93fee9d4d32519f36f4","facilitator":"cdp"},"seo_title":"XML Repair Skill That Changes No Text","seo_description":"Fixes XML that fails to parse, keeping every text node and CDATA as written, and refuses when two readings exist. Pay $0.05 once, in USDC.","versions":[{"version":"1.0.0","date":"2026-10-08","changelog":"# Changelog\n\n## 1.0.0 — 2026-10-08\n\nFirst 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.\n\nGrammar 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).\n\nPrice to be set after the baseline run (start $0.05).\n\n## Test 2026-10-08\n\n- Measured (Sonnet, one run per document, 24 documents, fence removed on the bare side): with the skill 24 of 24, without 17 of 24. Haiku: with 24 of 24, without 18 of 24.\n- Check widened for both sides after the run: items-not-closed now accepts the exact sibling repair (text unchanged, whitespace around the end tags free) as well as CANNOT REPAIR; the nested reading, changed text and an added node still fail (control.mjs updated; its old wrong answer was the sibling form, now the nested form).\n- Price set to $0.05 (Sonnet gain 7, no owner-measured facts).\n"}]}