Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am trying to convert XSD file to XML file using c# code. I am having the Xsd file as following. Can anybody help me how to convert it to xml file.....



MSIL
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:simpleType name="GUID">
    <xsd:annotation>
      <xsd:documentation xml:lang="en"> The representation of a GUID, generally the id of an element. </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}" />
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:element name="User">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Id" type="GUID" />
        <xsd:element name="EntityName" type="xsd:string" />
        <xsd:element name="Name" type="xsd:string" />
        <xsd:element name="Description" type="xsd:string" />
        <xsd:element name="Role" type="GUID" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>



Thanks in advance.
Posted
Updated 29-Feb-16 19:30pm

There is a tool XSD.exe which you can download and use it to convert your xsd file to xml or .cs class file and other types. It is available at MSDN: XML Schema Definition Tool (Xsd.exe)[^]
 
Share this answer
 
v3
You can get and write the xml from your dataset, check MSDN[^] for code examples on the get and write methods.
 
Share this answer
 
An xsd file describes HOW your data is to be presented in XML but xsd does NOT contain any data.

To write an XML file, you need some data that matches the xsd items. Then it's pretty easy as above.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900