When I do that, it returns 0: 0.

If I don't have a where clause on the statement, it returns the correct number of rows 9, outputs 0:9.

If I include the first part of the where clause (MessageName = :tMessageName)   and omit the second (Identifier= :tIdentifier) it returns 7, which is a value I'd expect. Having both returns 0, and I have checked the spelling of the second variable which is correct.

Yes, I can see that might help. I'm writing the following class to XML

Class OutputData Extends (%Persistent, %XML.Adaptor)
{ 
Parameter XMLNAME = "OutputData"; 
Property Notes As %String(MAXLEN = "", XMLNAME = "Notes", XMLPROJECTION = "ATTRIBUTE");
}

Using the following code

#dim item as DATAEXTRACTION.Datix.Message.Fragment.NewClass1 
set item = ##class(DATAEXTRACTION.Datix.Message.Fragment.NewClass1).%New()
set item.Notes = "< > &" _$c(10)_$c(13)_ "TEST" 

#dim tWriter as %XML.Writer
set tWriter=##class(%XML.Writer).%New()
set tWriter.Indent=4 
do tWriter.OutputToFile("E:\Testing\out.xml") 
set tSC=tWriter.RootObject(item)

Which produces the following XML, the $C(10) and $C(13) are not encoded, but the other characters are:

<?xml version="1.0" encoding="UTF-8"?>
<OutputData Notes="&lt; &gt; &amp;

TEST"></OutputData>

And what I want is:

<?xml version="1.0" encoding="UTF-8"?>
<OutputData Notes="&lt; &gt; &amp; &#xA; &#XD; TEST"></OutputData>

The reason for wanting this is that I'm building a new system to replace some legacy code and the data outputted by the new system has to be identical

I'll give it a try - how would I do that, I'm still new to objectscript at the moment.

Making the following change

 Property PersonIDs As list Of %String(XMLNAME = "PersonIDs", XMLPROJECTION = "ELEMENT");

Results in an error of:

ERROR #6232: Datatype validation failed for tag, PersonIDs (ending at line 9 character 15), with value:
1