Return an ASP.NET XML DATASET WITHOUT THE SCHEMA

Hi,

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="http://education.co">
- <xs:schema id="datareader" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" 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" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:choice>
  </xs:complexType>
  </xs:element>
  </xs:schema>
- <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">
  <UserName>spirit_sys</UserName>
  <Password>Gh05t5ly</Password>
  <EstablishmentFullName>Gravesend Grammar School</EstablishmentFullName>
  <Address1>Church Walk</Address1>
  <Address2>Milton</Address2>
  <Town>GRAVESEND</Town>
  <County>Kent</County>
  <Postcode>DA12 2PR</Postcode>
  <Authority>Kent</Authority>
  <Telephone>01474 331893</Telephone>
  <Fax>01474 331894</Fax>
  <PupilsonRoll>1000</PupilsonRoll>
  <EducationNumber>17219</EducationNumber>
  <KB_ID>15</KB_ID>
  </Results>
  </datareader>
  </diffgr:diffgram>
  </DataSet>

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



thanks
LVL 2
kintonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

e1vCommented:
For a typed dataset you can set DataSet.SchemaSerializationMode = SchemaSerializationMode.ExcludeSchema;
e1vCommented:
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();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

thanks
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

e1vCommented:
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

[WebMethod]
public XmlDocument ReturnXmlDoc()
{
StringWriter sw = new StringWriter();
yourDataSet.WriteXml(sw, XmlWriteMode.DiffGram);
XmlDocument doc = new XmlDocument();
doc.LoadXml(sw.ToString());
return doc;
}
e1vCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.