• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Creating XSD from XML data

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    XSD can be generated from XML using MS XML Schema Generation Tool.

    See the following link

    http://msdn2.microsoft.com/en-us/lib...0s(vs.80).aspx
    please do not ask for money...
    as a smack in the mouth often offends

    Comment


      #12
      vb.net code to do it


      Dim doc As New XmlDocument
      Dim sr As New System.IO.StreamReader("C:\foo.xml")
      Dim xmlS As String = sr.ReadToEnd
      sr.Close()
      doc.LoadXml(xmlS)
      Dim ds As DataSet = New DataSet

      ds.ReadXml("C:\foo.xml")

      ds.WriteXmlSchema("C:\foo.xsd")


      works fine but obviously the XSD isnt the most useful thing in the world. i did it the other day as i wanted to generate a strongly typed dataset from some XML in a spec (no XSD provided)

      HTH

      Comment


        #13
        no one mentioned the xsd tool ?

        xsd/?
        Microsoft (R) Xml Schemas/DataTypes support utility
        [Microsoft (R) .NET Framework, Version 2.0.50727.42]
        Copyright (C) Microsoft Corporation. All rights reserved.

        xsd.exe -
        Utility to generate schema or class files from given source.

        xsd.exe <schema>.xsd /classes|dataset [/e:] [/l:] [/n:] [/o:] [/s] [/uri:]
        xsd.exe <assembly>.dll|.exe [/outputdir:] [/type: [...]]
        xsd.exe <instance>.xml [/outputdir:]
        xsd.exe <schema>.xdr [/outputdir:]

        Comment


          #14
          Originally posted by jim2406
          vb.net code to do it


          Dim doc As New XmlDocument
          Dim sr As New System.IO.StreamReader("C:\foo.xml")
          Dim xmlS As String = sr.ReadToEnd
          sr.Close()
          doc.LoadXml(xmlS)
          Dim ds As DataSet = New DataSet

          ds.ReadXml("C:\foo.xml")

          ds.WriteXmlSchema("C:\foo.xsd")


          works fine but obviously the XSD isnt the most useful thing in the world. i did it the other day as i wanted to generate a strongly typed dataset from some XML in a spec (no XSD provided)

          HTH
          About as useful as a chocolate teapot unless you happen to want a typed dataset schema!

          Really, a million schemas can represent one XML document. The best xsd tool is the human brain. It ain't hard, and it is much more likely to represent an intelligent schema representation of the XML document (assuming you know something about what the XML means and is to be used for), than these tools.

          Comment


            #15
            The strongly typed dataset was a requirement (not dictated by myself) to make a specific region of code easier to maintain.

            I wasn't arguing the merits (or otherwise) of the question posted by the original poster I was just offering a solution..

            Comment

            Working...
            X