farciarz84: doubling the ' is correct
farciarz84: alternatively, if the query is a constant string, you might prefer this form:
farciarz84: query_to_xml($q$ select * from my_table where some field = '' $q$, ...
farciarz84: the $q$...$q$ is a dollar-quoted string, which can contain any sequence of characters, with no escaping - but the specific $...$ string used to delimit it cannot appear in the content
farciarz84: so it's only really appropriate for constants where you know in advance that the delimiter string is not present