amp in an XML


I have a question about & being transmitted in a XML from a sendor to a vendor. Should the conversion from & to & be made by the sender or the receiver. Also is there a standard document on the web that states it.



I’m not sure what you are asking.

When in an XML file the & must be a & or it must be in a CDATA or processing instruction or Comment section [1], otherwise you don’t have XML. Whoever creates the XML should create legal XML. For instance, if you use IS 4.6 pub.web:recordToDocument to create the XML and there are & in the data, you should set the encode parameter to true.

Whoever takes data out of XML should unencode or allow the application to un-encode it. For instance, if you use IS 4.6 pub.web:queryDocument to get text from a parsed XML document, the text will be decoded before being put into the pipeline.



Hi Fred,

The question that i had was Can a Sender (A) post an XML
<a > Test & Test </a> to receiver (B), who if required converts the & to &
Is there a strict rule that A should send it as

  1. <a > Test & Test </a> (B does the conversion if required) or
  2. <a > Test & Test </a> (A does the conversion)
    only or it depends upon the understanding between the sender and receiver (as to who will convert it from & to &
    and both xmls (1 and 2) are valid.

Thanks in advance,


The rule is that to have a “well formed” and “valid” XML document the ampersand “&” must be formatted properly.

No formatting equals an invalid document.

What Jim and I are saying is that “post an XML <a > Test & Test </a> to receiver (B)” is not possible because “<a > Test & Test </a>” is not XML. So the direct answer is “the Sender has to encode the data into XML before sending XML”.

If the XML text is not encoded correctly, most parsers will exception when parsing the XML, so receiver B will never have a chance to get any of the data. I don’t know of any parsers that would allow ignoring or turning off this kind of XML syntax check.

Hi Fred and Jim,

Thanks for your help.
So to confirm The characters & <> ’ " must be encoded before transmitting.
Let me know if there any other characters that need to be transmitted.



There is predefined set of entities in the XML Spec for less than, greater than, amp, apos, quot.