Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

xsd to xml

Posted on 2004-08-20
6
Medium Priority
?
581 Views
Last Modified: 2012-05-05
Given an xsd file, is it possible to generate an xml file?





0
Comment
Question by:doudou74
  • 2
4 Comments
 
LVL 10

Expert Comment

by:eternal_21
ID: 11852214
An XSD file is in XML format.... what exactly are you trying to do?
0
 

Author Comment

by:doudou74
ID: 11852328
I have a schema .xsd,
and i need to get a .xml file that corresponds to this xsd.

a .xsd defines just the structure.
the xml file contains data values.


0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 500 total points
ID: 11853158
Do you have a Strongly Typed dataset in your application?  You can produce the XML string with this:

  public static string WriteDataSet(System.Data.DataSet dataSet)
  {
    System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
    dataSet.WriteXml(memoryStream, System.Data.XmlWriteMode.WriteSchema);
    memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
    return new System.IO.StreamReader(memoryStream).ReadToEnd();
  }

Personally, I use the System.Data.XmlWriteMode.IgnoreSchema option.
0
 
LVL 10

Expert Comment

by:123654789987
ID: 11868188
You can do it using some tools using XmlSpy.

If you want to do it programatically there is a tool called XML Schema Definition Tool (Xsd.exe)
You can get information about this tool from MSDN.

There is a particular option called XSd sample.xsd /d  which
Generates a class derived from DataSet that corresponds to the specified schema.
Then from this dataset
To read XML data into the derived class, use the System.Data.DataSet.ReadXml method.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question