0

How can I generate a xsd file from a XML file using vb.net code?

1
  • 1
    You can generate an XSD file from an XML file programmatically, and get an XSD that the XML conforms to, but it's not likely to be very useful. For example, it may well constrain all postcodes to have the pattern AA99 9AA, just because all the postcodes in your sample XML conform to that pattern. In practice to get a useful schema, you need human intervention. Commented Feb 21, 2020 at 21:44

1 Answer 1

1

I found this answer and converted it to vb.net

Using reader = XmlReader.Create("filename.xml")
    Dim schemaInference = New XmlSchemaInference()
    Dim schemaSet = schemaInference.InferSchema(reader)
    For Each s As XmlSchema In schemaSet.Schemas()
        Using writer = XmlWriter.Create("schema.xsd")
            s.Write(writer)
        End Using
    Next
End Using

Sometimes it helps to learn about this thing called a search engine. You may have heard of a search engine. If so, you can try to search one too!

Try this

generate xsd from xml vb.net site stackoverflow.com

and if that doesn't work, you can always look for c# answers because they are more abundant

generate xsd from xml c# site stackoverflow.com

The answer I found was in the first result of the search engine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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