Generating XML from another database

Below is a clip of my code I ma using to generate XML from another database. I have one database that is open to the web that gathers info from other databases. I have an agent for each database that I want to gather data from. The agents work on most databases, however on this database the Type field contains &'s in the values. I can’t change them and can’t nest the cdata. I have looked at the replace ( ) but have had no luck.

I am also having an issue with the web details field as it is a text field that contains line breaks. It there a way to place a carriage return value where a line break occurs when the for is filled out?

Could someone please point me in the right direction. I have looked at the XML for domino, but that is more of an input guide rather than output.

Thanks in advance.

While Not ( doc Is Nothing )

'send the parent element for each Section document

	

	If doc.Type(0) <> currentKeyword Then

		Print "<Type>"+doc.Type(0)

		currentKeyword = doc.Type(0)   ' <-- moved this back up here

	End If

	

       'send appropriate markup, pulling field content

       'from the document object

	Print "<![CDATA["

	Print "<Date>"+doc.StartDate(0)

	Print "<Time>"+doc.StartTime(0)+"</Time>"

	Print "<Subject>"+doc.Subject(0)+"</Subject>"

	Print "<Location>"+doc.Location(0)+"</Location>"

	Print "<Details>"+doc.WebDetails(0)+"</Details>"

	Print "<Link>"+doc.AttachFN(0)+"</Link>"

	Print "<WebLink>"+doc.ActualWebLink(0)+"</WebLink>"

	Print "</Date>"

	Print "]]>"

       'get the next document in the view

	Set doc = view.GetNextDocument( doc )

	

	If doc Is Nothing Then   ' Moved this test after the new doc is retrieved

		Print "</Type>"

		

	Else 

		If doc.Type(0) <> currentKeyword Then

			Print "</Type>"

			

		End If

	End If