title: How to read a RichText field?
body: <p>I have an agent which is supposed to show a Notes DB as XML. I successfully retrieved all the fields but the RichText one. This is a code snippet:</p>
  
  <pre><code>Set session = New NotesSession
  Set doc = session.DocumentContext
  Set db = Session.CurrentDatabase
  Set view = db.getview("myView")
  Set doc = view.GetFirstDocument()
  
  While Not(doc Is Nothing)
      Print "&lt;job&gt;"
      Print "&lt;id&gt;" &amp; doc.id(0) &amp; "&lt;/id&gt;" ' Works fine since ID is a normal field
      Print "&lt;text&gt;" &amp; doc.text(0) &amp; "&lt;/text&gt;" ' Does not work at all 
      Print "&lt;/job&gt;"
      Set doc = view.GetNextDocument(doc)
  Wend
  </code></pre>
  
  <p>If I use doc.text instead of doc.text(0) it only writes the first two words of the whole text. I suppose I have to cicle through the entire text but since I am new to Lotus Script I have no idea how to do it. Thank you guys.</p>
  
  <p>EDIT: It turned out that Simon's answer is correct. The problem regards encoding as far as I can tell, if I remove the following Print:</p>
  
  <pre><code>Print |Content-Type:text/xml| &amp; Chr$(13)
  </code></pre>
  
  <p>Everything works fine. I guess I need to define encoding in the header...</p>
  
  <p>EDIT: I now use this Print instead:</p>
  
  <pre><code>Print "&lt;text&gt;&lt;![CDATA[" &amp; rtitem.getUnformattedText() &amp; "]]&gt;&lt;/text&gt;"
  </code></pre>
  
  <p>However when I call the agent from the Browser it still broke at that print as it is ignoring the CDATA.</p>