XmlTextWriter produces processing instruction

This week I've been producing XML Thesaurus files for SQL Server. The prupose is to enable spell checking in full text. The thesaurus file is an XML file wih a defined schema, I was creating the file with an XmlTextWriter but couldn't for hte life of me get it to load.

After much digging I realised the issue was that my XML file had a processing instruction in it (<?xml version="1.0" encoding="utf-16"?>), this is standard in a most XML files but unfortunately it causes full text to fail the file.

So how do you stop the the XmlTextWriter from producing the processing instruction. Its not straight forward to find out, but it is straight forward to implement. Simply you don't use the WriteStartDocument method. All this does is write the processing instruction. Pretty obvious really.



-
Published 22 September 2007 22:51 by simonsabin

Comments

No Comments