Knowledge.ToString()

Generate Sample XML Data From XSD Using Visual Studio

If you have an XSD file, it is difficult to visualize how the XML file structure looks like. As a developer, you are mostly dealing with XML. As XML file quickly visualizes the data structure, you are looking for a way to get XML file with dummy data from a given XSD file.

Visual Studio provides a quick way to generate sample XML file with dummy data from XSD file.

Here is a step by step guidance.

Step By Step Guide to Generate Sample XML From XSD File

Open Visual Studio.

Drag XSD file on Visual Studio or go to Visual Studio > File > Open > File and select the XSD file to open.

Click on “XML Schema Explorer” as shown in the image below.

Visual Studio open XSD file

Within “XML Schema Explorer” scroll all the way down to find the root/data node.

Right click on root/data node and it will show “Generate Sample XML”.

If it does not show option “Generate Sample XML”, it means you are not on the data element node but you are on any of the data definition node.

Visual Studio XSD file Generate Sample XML Data

Namespace Error

If you face difficulty generating the sample XML data and encounter error regarding namespace, resolve xsd namespace error by following these steps.

Share

Comments

3 responses to “Generate Sample XML Data From XSD Using Visual Studio”

  1. Abdelghani Avatar
    Abdelghani

    Nothing to say except thank you so much 🙂

  2. David Burg Avatar
    David Burg

    For all optional fields the default behavior for the Visual Studio generator is to write a xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:nil=”true” attribue. Is there any configuration option to get the generator to instead write a sample non-null payload?

  3. Robert Avatar
    Robert

    In MS VS 2008 there is no “XML Schema Explorer” …:(

Leave a Reply

Your email address will not be published. Required fields are marked *