Hi
I keep getting error :
WriteStartDocum ent cannot be called on writers created with
ConformanceLeve l.Fragment.
The code that I have is very simple.
SimpleClass c = new SimpleClass();
c.Name = "TestName";
XmlSerializer serializer = new XmlSerializer(t ypeof(SimpleCla ss));
MemoryStream stream =new MemoryStream();
XmlWriterSettin gs settings = new XmlWriterSettin gs();
settings.OmitXm lDeclaration = true;
settings.Confor manceLevel = ConformanceLeve l.Fragment;
settings.Encodi ng = Encoding.ASCII;
XmlWriter writer = XmlWriter.Creat e(stream,settin gs);
serializer.Seri alize(writer,c) ;
stream.Position = 0;
byte[] data=new byte[stream.Length];
stream.Read(dat a, 0, (int)stream.Len gth);
result = new string(Encoding .Default.GetCha rs(data));
I found in documentation that if there is DTD information that
WriteStartDocum ent will be called and with ConformanceLeve l.Fragment writer
will throw an exception.
So where is DTD information? Can I remove it to make this work?
Thanks.
Shimon
I keep getting error :
WriteStartDocum ent cannot be called on writers created with
ConformanceLeve l.Fragment.
The code that I have is very simple.
SimpleClass c = new SimpleClass();
c.Name = "TestName";
XmlSerializer serializer = new XmlSerializer(t ypeof(SimpleCla ss));
MemoryStream stream =new MemoryStream();
XmlWriterSettin gs settings = new XmlWriterSettin gs();
settings.OmitXm lDeclaration = true;
settings.Confor manceLevel = ConformanceLeve l.Fragment;
settings.Encodi ng = Encoding.ASCII;
XmlWriter writer = XmlWriter.Creat e(stream,settin gs);
serializer.Seri alize(writer,c) ;
stream.Position = 0;
byte[] data=new byte[stream.Length];
stream.Read(dat a, 0, (int)stream.Len gth);
result = new string(Encoding .Default.GetCha rs(data));
I found in documentation that if there is DTD information that
WriteStartDocum ent will be called and with ConformanceLeve l.Fragment writer
will throw an exception.
So where is DTD information? Can I remove it to make this work?
Thanks.
Shimon
Comment