I have produced an XML Web Service in ASP 2.0, this returns a dataset.  The output is below:

  <?xml version="1.0" encoding="utf-8" ?>
- <DataSet xmlns="">
- <xs:schema id="datareader" xmlns="" xmlns:xs="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="datareader" msdata:IsDataSet="true" msdata:Locale="en-US">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="Results">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="UserName" type="xs:string" minOccurs="0" />
  <xs:element name="Password" type="xs:string" minOccurs="0" />
  <xs:element name="EstablishmentFullName" type="xs:string" minOccurs="0" />
  <xs:element name="Address1" type="xs:string" minOccurs="0" />
  <xs:element name="Address2" type="xs:string" minOccurs="0" />
  <xs:element name="Town" type="xs:string" minOccurs="0" />
  <xs:element name="County" type="xs:string" minOccurs="0" />
  <xs:element name="Postcode" type="xs:string" minOccurs="0" />
  <xs:element name="Authority" type="xs:string" minOccurs="0" />
  <xs:element name="Telephone" type="xs:string" minOccurs="0" />
  <xs:element name="Fax" type="xs:string" minOccurs="0" />
  <xs:element name="PupilsonRoll" type="xs:string" minOccurs="0" />
  <xs:element name="EducationNumber" type="xs:string" minOccurs="0" />
  <xs:element name="KB_ID" type="xs:string" minOccurs="0" />
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <datareader xmlns="">
- <Results diffgr:id="Results1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
  <EstablishmentFullName>Gravesend Grammar School</EstablishmentFullName>
  <Address1>Church Walk</Address1>
  <Postcode>DA12 2PR</Postcode>
  <Telephone>01474 331893</Telephone>
  <Fax>01474 331894</Fax>

I want to remove the schema at the top.  I have searched higth and low and cannot find anything?  Is it even possible.  I have tried returning the dataset as string but this removes the row counter on every line.

I would really appreciate any help

Who is Participating?
Or if you want to return it as string but keep the rowcounter you can do this:

        StringWriter sw = new StringWriter();
        DataSet.WriteXml(sw, XmlWriteMode.DiffGram);
        return sw.ToString();
For a typed dataset you can set DataSet.SchemaSerializationMode = SchemaSerializationMode.ExcludeSchema;
kintonAuthor Commented:
Hi e1v,

The method to return as a string works almost perfectly,however,the closing tags are replaced with &gt and the opening with @Lt the source file of the page returned,any idea why?  The person I am writing this for is consuming it with PHP and has suggested this will be a problem for them.  I don't quite understand why as the actual output appears fine!!?

The method you suggested to keep it as a dataset returns this error message "SchemaSerializationMode property can be set only if it is overridden by derived DataSet".  Any ideas why?

I appreciate my first paragraph is a seperate question,and if necessary I am prepared to post it as one and award you the points for your answer about returning it as a string.

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

I suppose the SchemaSerializationMode errormessage mens that can only be set on a typed dataset, that is a dataset generated from a xsd, not on a generic DataSet (like DataSet ds = new DataSet())

As for the problem you have with string it probably has to do with the string encoding, you could try using an XmlTextWriter and experimenting with different System.Text.Encoding...) , but I

Another suggesiton would be to return a xmldocument like this

public XmlDocument ReturnXmlDoc()
StringWriter sw = new StringWriter();
yourDataSet.WriteXml(sw, XmlWriteMode.DiffGram);
XmlDocument doc = new XmlDocument();
return doc;
Sorry for the typos above, but I was really in a hurry...(approaching deadline at work..)

I don't remember what I started writing where I wrote 'but I'...  
kintonAuthor Commented:
thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.