I have several types of XML document.

The format of (i.e. the elements in) each document type is defined in an XSD.

Is there a convenient way to create HTML elements (or ASP.NET controls) on an ASP.NET form, to display/edit the elements in (contents of) an XML document, given the XML document and/or the document's XSD definition as input?

Within the XML/XSD:

  • Complex (i.e. parent) elements may contain sub-elements
  • Simple elements are of type 'string', 'integer', 'list of string values', etc.: which should map to corresponding HTML input elements
  • Elements are documented (labelled) using <xs:annotation> in the XSD (these would be suitable HTML <label> elements for the corresponding <input> elements).
  • Each element is required, not required, and/or there may be several of them, specified using minOccurs and maxOccurs in the XSD

As well as generating the ASP.NET form, when the user posts the completed form, the software should read the returned data and pack it into an XML document.

How to do this?

I can write software to parse the XSD and generate the forms myself but that seems like a lot of code to write in-house and maintain.

  • Do you have an XSLT or an XML schema (XSD)? Jan 22, 2014 at 15:34
  • @WyattBarnett I have an XSD. Thanks for the correction.
    – ChrisW
    Jan 22, 2014 at 15:39
  • If you were that way inclined you could probably write some kind of XSLT to convert the XSD into an ASP.Net page. Wouldn't surprise me if someone's done it already... :) Jan 22, 2014 at 17:31
  • @RobertHarvey I see only "The member requested was not found." from that URL. Do you know the name of the project or title of the article you were referring to?
    – ChrisW
    Jan 22, 2014 at 22:02
  • Ack. Apparently you need the descriptive part of the URL on CodeProject, or it won't work: codeproject.com/Articles/38277/… Jan 22, 2014 at 22:12

1 Answer 1


There isn't a direct way that I'm aware of off the top of my head. But XSD to form was hawt back in 2001 when .NET was conceived so you can likely use tools like xsd.exe to generate a class from that. Then you should be able to use the EditorFor in ASP.NET to generate a form for that. Or any other form generator that takes classes as input.

  • xsd2code is a similar utility that will generate a class for you that you can then use in conjunction with EditorFor, although EditorFor may only be applicable to ASP.NET MVC. Not sure it EditorFor is applicable to WebForms. Which are you using?
    – maelstrom
    Jan 22, 2014 at 20:39
  • Thanks for the hint. I don't know yet whether I'll go this route. I found many alternatives to xsd.exe at stackoverflow.com/questions/386155/…
    – ChrisW
    Jan 23, 2014 at 3:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.