Hi
I keep getting error :
WriteStartDocument cannot be called on writers created with
ConformanceLevel.Fragment.
The code that I have is very simple.
SimpleClass c = new SimpleClass();
c.Name = "TestName";
XmlSerializer serializer = new XmlSerializer(typeof(SimpleClass));
MemoryStream stream =new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.Encoding = Encoding.ASCII;
XmlWriter writer = XmlWriter.Create(stream,settings);
serializer.Serialize(writer,c);
stream.Position = 0;
byte[] data=new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
result = new string(Encoding.Default.GetChars(data));
I found in documentation that if there is DTD information that
WriteStartDocument will be called and with ConformanceLevel.Fragment writer
will throw an exception.
So where is DTD information? Can I remove it to make this work?
Thanks.
Shimon