Dataset -> XML Document - Load DataSet into an XML Document - C#.Net

Posted by NLV on Stack Overflow See other posts from Stack Overflow or by NLV
Published on 2010-04-19T11:47:52Z Indexed on 2010/04/19 12:23 UTC
Read the original article Hit count: 752

Filed under:
|
|

Hello

I'm trying to read a dataset as xml and load it into an XML Document.

XmlDocument contractHistoryXMLSchemaDoc = new XmlDocument();

using (MemoryStream ms = new MemoryStream())
{
   //XmlWriterSettings xmlWSettings = new XmlWriterSettings();

   //xmlWSettings.ConformanceLevel = ConformanceLevel.Auto;
   using (XmlWriter xmlW = XmlWriter.Create(ms))
   {
      xmlW.WriteStartDocument();
      dsContract.WriteXmlSchema(xmlW);
      xmlW.WriteEndDocument();
      xmlW.Close();
      using (XmlReader xmlR = XmlReader.Create(ms))
      {
         contractHistoryXMLSchemaDoc.Load(xmlR);
      }
   }
}

But I'm getting the error - "Root Element Missing".

Any ideas?

Update

When i do xmlR.ReadInnerXML() it is empty. Does anyone know why?

NLV

© Stack Overflow or respective owner

Related posts about Xml

Related posts about dataset