Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

xsd to xml

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





0
Comment
Question by:doudou74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 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

Technology Partners: 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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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…
Suggested Courses

730 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