24

Is there an IDE out there that can generate XML from XSD? Not Oxygen or XmlSpy, they are too expensive for me... command line based is ofcourse the preferred method!

eddy147
  • 4,853
  • 8
  • 38
  • 57
  • 1
    Right clicking on Visual Studio Schema Explorer generates sample XML: http://msdn.microsoft.com/en-us/library/dd489258.aspx – Juha Palomäki Nov 25 '14 at 21:20

8 Answers8

17

The Netbeans IDE has a wizard for generating XML documents from an XSD schema. A nice thing is that you can also ask it to generate optional and repeating elements too.

user22940
  • 194
  • 2
  • thank you, i love netbeans, didnt know this option :) – eddy147 Jan 15 '09 at 11:54
  • 6
    where is the menu located? – Louis Rhys Sep 30 '11 at 10:44
  • 1
    IntelliJ also has support for doing this :) – Blake Pettersson Feb 21 '12 at 16:40
  • 3
    @Louis: http://stackoverflow.com/questions/7811715/use-netbeans-to-create-sample-xml-from-xsd – eddy147 Mar 13 '12 at 07:31
  • I have tried many options for this and have found [Oxygen](https://www.oxygenxml.com/) to be the best. It is commercial but does offer a free trial. I have used this to generate XMLs from the most bloated schema ever: [DDEX ERN](https://github.com/sshaw/ddex/blob/ea976d60c5f72e0fea0f5f3239a2125509bd3dbd/etc/schemas/ern/42/release-notification.xsd) and it worked great. The others couldn't do it. – sshaw Feb 05 '22 at 17:29
9

You can do it in the Eclipse Web Tools (included in the Eclipse IDE for Java EE Developers).

Fabian Steeg
  • 44,988
  • 7
  • 85
  • 112
7

How to generate sample XML documents from their DTD or XSD?

Community
  • 1
  • 1
lindelof
  • 34,556
  • 31
  • 99
  • 140
5

Note that soon after this answer was originally posted, Apache XMLBeans was retired. As such, I cannot recommend it anymore. Anyway, I am still of the opinion that it had good command line support for generating example xsd:s, but a new release haven't been done in well over 2 years at time of writing.


command line based is ofcourse the preferred method!

In my opinion xsd2inst in the Apache XMLBeans is a very good tool for this. It is command line based and ships with binaries for Windows and Unix/Linux.

It is really simple to use too:

xsd2inst schemafile.xsd -name globalElementName

It generates the output directly to the console and can of course easily be piped to a file.

Is there an IDE out there that can generate XML from XSD?

IntelliJ Idea has the same functionality if using an IDE is prefered, even in the community edition. Just right click inside the xsd document and select Generate Instance Document From Schema, then select the root node.

Magnilex
  • 11,584
  • 9
  • 62
  • 84
  • What program is IntelliJ using under the hood to generate it? – powder366 Feb 19 '17 at 17:57
  • @powder366 Good question. I don't actually know. The IntelliJ docuemtnation about this feature doesn't say which tool it uses either. – Magnilex Feb 19 '17 at 19:11
  • It also doesn't really work, for me this functionality in IntelliJ always says "Root element name is invalid" whatever I try, "Ok" button remains inactive. – Czar Sep 24 '18 at 11:34
  • @Czar It was a few years ago I answered this. It worked well then, for well formed xds:s. I haven't done it much since then though. – Magnilex Sep 24 '18 at 19:03
1

The .NET XML transform classes are pretty easy to use, so if you can't find something, it would be pretty easy to whip together a simple command line utility to do what you want.

Rob Prouse
  • 22,161
  • 4
  • 69
  • 89
1

The free online XML editor XmlGrid.net has an option to generate XML from schema XSD. The nice thing is that you can specify how many repeatable elements you want and can fill the elements with the default values provided in your schema. It can handle very complicated schemas. Here is the url: http://xmlgrid.net

Zac Zeng
  • 11
  • 1
  • It doesn’t seem to work with my XSD. Opera, FF, Chrome, IE... Nothing happens; I just see several errors on the various console. Not very robust, apparently. – Martijn Feb 08 '13 at 14:44
0

I used this link: i use c#. but this is a simple step. Load the xsd, generate xml. It generates a sample xml for and element 3 times. http://www.codeproject.com/Articles/400016/Generate-Sample-XML-from-XSD?msg=4279868

sam
  • 320
  • 3
  • 14
0

Useful online utility to Create XML Data From an XSD Schema File http://www.xsd2xml.com/