Two encodings, two different jobs
A supplier copies a valid address containing query parameters into a sitemap. The browser address contains an ampersand, while the XML source needs an escaped representation. Another supplier encodes the entire URL again and changes an existing percent escape. Both files may look plausible in a text editor, but the important question is which exact address an XML reader obtains.
Keep the approved address outside the serializer
The sitemap protocol requires UTF-8 and entity escaping of values. Our exercise starts with already approved, already URL-encoded addresses and checks only their XML representation. It does not choose canonical pages, repair malformed business URLs or decode query values. Those decisions belong upstream. The original input list is retained as the comparison, rather than reconstructed from the candidate output.
Replay the filled address pair
The synthetic first address is https://cedar.example/services/?area=inner%20north&kind=fitout. Its XML text contains & between the two parameters, while the percent escape remains %20. Parsing the XML must recover the original address exactly. The second address includes the query value A%2BB and a quoted label. It tests that the plus encoding and quote characters survive the same round trip. Neither address is a live customer destination.
Challenge the plausible failures
A raw ampersand can make the XML fail to parse. Replacing it twice can produce a valid XML file whose parsed URL contains the literal characters amp; in the query. Replacing %20 with %2520 can also leave the XML valid while changing the address. These are separate failures: parsing is necessary, but equality with the approved URL list is what detects the latter two. Do not accept a green parser badge as a content-preservation result.
Run the finite local check
Download roundtrip.py, filled-input.json and test_roundtrip.py into one folder. With Python 3.10 or newer, run the two commands below. The supplied program creates XML, parses it and compares the ordered URL list. Its tests cover raw ampersands, double escaping, altered percent escapes, missing entries and quoted characters. Empty lists, credentials in URLs and malformed percent escapes are rejected under this teaching contract. No network request or sitemap submission occurs.
Separate syntax from publication acceptance
For a real handover, retain the approved URL inventory, generator version, exact output bytes and parsed comparison result. Then independently check file location, host authority, size limits, indexability and the actual published response. The small program is deliberately not a complete sitemap validator and cannot determine whether Google read or indexed a URL. It also cannot authorise a change to an existing address or sitemap.
Filled review cases
All examples are synthetic teaching records, not client results or live search measurements. Scroll the table on narrow screens.
| Input | Output | Interpretation |
|---|---|---|
| A · Approved query URL serialised once | EXACT_URL_ROUNDTRIP | Compare parsed loc with the original string |
| B · Raw ampersand in candidate XML | XML_PARSE_FAILED | Preserve malformed output for diagnosis |
| C · Double-escaped ampersand | URL_LIST_MISMATCH | Valid XML can still change the address |
| D · %20 replaced by %2520 | URL_LIST_MISMATCH | Do not encode the entire approved URL again |
Deliver the evidence
- Approve complete URL strings before generating XML.
- Serialize once, parse the result and compare against the unchanged input list.
- Keep actual publication and search processing as separate checks.
Sitemaps protocol documentation · Supporting passages checked 6 November 2026. Case labels and review procedures are our original teaching design; they are not Google certification rules.
filled-review.json · README.txt · roundtrip.py · filled-input.json · actual-output.json · test_roundtrip.py
python3 -B roundtrip.py filled-input.json
python3 -B -m unittest -v test_roundtrip.py