articles

Home / DeveloperSection / Articles / Creating XSD of a XML using Visual studio

Creating XSD of a XML using Visual studio

Devesh Omar4001 19-May-2014
Introduction

I would like to share a simple way to create XSD of a sample Xml file. XSD is a

schema document which is used to validate a xml file.

It validates following things:

a.       Data type of tags (value of tags)

b.      Sequence of tags

c.       Parent-child relationship between tags etc.

 

Sample xml file
<?xml version="1.0"?>
<ORDERDETAILS>
<ORDER>
<ORDERID>1234</ORDERID>
<PRODUCTID>0090</PRODUCTID>
<ORDERDATE>23-07-2013</ORDERDATE>
<CUSTOMERID>x4564<CUSTOMERID>
</ORDER>
<ORDER>
<ORDERID>1235</ORDERID>
<PRODUCTID>0030</PRODUCTID>
<ORDERDATE>23-07-2013</ORDERDATE>
<CUSTOMERID>x4334<CUSTOMERID>
</ORDER>
</ORDERDETAILS>

   Steps

1)      Open visual studio and create a xml file as per below.


Creating XSD of a XML using Visual studio

2)      Go to XML menu option and click on schema button 


Creating XSD of a XML using Visual studio      


3)      After clicking on schema option we will have xsd of above sample xml file


Creating XSD of a XML using Visual studio 


4)      We can change data type of tags as per below screen.


Creating XSD of a XML using Visual studio      


5)      I changed the data type of PRODCUTID tag to integer. And saved it.


Creating XSD of a XML using Visual studio

6)      Now I changed value of PRODUCT ID tag to some string value.  It starts

validating to created xsd file.


Now as we changed the value of product id, it starts showing error as per below

screen.

 

Creating XSD of a XML using Visual studio

 

Conclusion

Creating XSD of XML file is very simple if we follow above steps.


Updated 07-Sep-2019
I am Software Professional

Leave Comment

Comments

Liked By