Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 583
  • Last Modified:

xsd to xml

Given an xsd file, is it possible to generate an xml file?





0
doudou74
Asked:
doudou74
  • 2
1 Solution
 
eternal_21Commented:
An XSD file is in XML format.... what exactly are you trying to do?
0
 
doudou74Author Commented:
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
 
eternal_21Commented:
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
 
123654789987Commented:
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
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.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now