xml-escape-string

xml-escape-string is a compiled Lisp function in `xml.el'.

(xml-escape-string STRING)

Convert STRING into a string containing valid XML character data.
Replace occurrences of &<>'" in STRING with their default XML
entity references (e.g. replace each & with &).

XML character data must not contain & or < characters, nor the >
character under some circumstances. The XML spec does not impose
restriction on " or ', but we just substitute for these too
(as is permitted by the spec).