articles

home / developersection / articles / creating xsd of a xml using visual studio

Creating XSD of a XML using Visual studio

Devesh Omar 4.24 K 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.



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


      


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


 


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


      


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



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.

 

 

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