One very common issue that can occur when converting HL7 to XML
and back again is how to correctly treat the '&' character that
normally appears in the header of an HL7 message.
The '&' character is an escape character in XML and is
used to represent XML entities. XML entities are used to represent
special characters like
'<' and
'>' (represented as
< and
> respectively). Since the
& character is a special
character itself, it needs to also be escaped with the sequence
&. For this reason having a sequence like
<MSH.2>^~\&</MSH.2>
is illegal. The ampersand character must be escaped as follows:
<MSH.2>^~\&</MSH.2>.