Applies to: Protocol and format interpretation for developers inspecting authorized media delivery.

The useful distinctions

  • XML provides predefined entity references including amp, lt, gt, apos, and quot.
  • A literal ampersand in ordinary character data must be represented appropriately.
  • Character and entity references are resolved as part of XML processing.

Compare two layers of the same value

The title a person intends to store contains an ampersand and a less-than sign. The serialized document uses references so those characters cannot be mistaken for markup delimiters. After parsing, the application should receive the intended title, not the reference spelling. A useful export check starts with the original Unicode string, serializes it through an XML library, parses the result, and compares the returned string with the original. This tests the actual round trip instead of inspecting whether the output merely looks familiar.

Assign escaping to one boundary

Double escaping often appears when a database stores already escaped text and an XML writer escapes it again. For the intended ampersand, the output then contains amp followed by another escaped ampersand sequence and the reader may display reference-like text. Keep ordinary application text as characters and let the serializer handle XML syntax at the output boundary. Conversely, do not repair a document with a global replacement of every ampersand: that can damage correct references. The small example needs no custom entity declarations or remote DTD retrieval. Structural XML parsing and XMLTV semantic checks are separate tasks; a well-formed title can still sit in an invalid programme record.

Worked example · synthetic

The parsed title is exactly 'Ink & Paper: 2 < 3'. The references are serialization syntax and are not part of the title's character value.

Synthetic text example; no network operation has been performed.

<tv>
  <programme start="20261108120000 +0000" channel="workshop.example">
    <title>Ink &amp; Paper: 2 &lt; 3</title>
  </programme>
</tv>

Check the interpretation

  • Serialize with an XML-aware writer.
  • Compare parsed text to the original Unicode value.
  • Disable unwanted external entity resolution in a local validation workflow.