Replace place holders with the required value using XML templates

Hi,

I am using XML template to generate PDF document. Is there a way to replace place holders with certain value. Currently I have seen replacing content using id.

Suppose if I have following in the template,

I am able to replace the value in the following way.

Segment patientIDSeg =(Segment)section1.getObjectByID("patientID");
patientIDSeg.setContent("testid");

Is there a way to replace all the references to patientID in the document.

Thanks

Mamatha