Reputation: 345
Within the Azure API Management, I have an API, within its outbound policy I wish to find-and-replace like this;
<find-and-replace from="<" to="<" />
However, the "<" character is of course illegal since the policy itself is written in XML giving me the following error;
Error parsing policy xml document. '<', hexadecimal value 0x3C, is an invalid attribute character. Line 72, position 43.
Reason:
My backend API returns a text string which I want to "convert" into a valid XML.
Questions:
Upvotes: 1
Views: 2945
Reputation: 7810
Since you're want to convert "<" (that is three separate characters) to "<" AND you're writing an XML you have to double encode things. Try:
<find-and-replace from="&lt;" to="<" />
This way XML after XML decoding first string will become "<
", and second - "<
".
Note that this is not APIM problem, it's an XML encoding problem, for example this code:
new XElement("el", new XAttribute("at", "<")).ToString()
produces such XML:
<el at="&lt;" />
Upvotes: 3