(E-Mail Removed) wrote:
> <note>
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
>
> With above, I would like to create
>
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com"
The XML instance documents has elements in no namespace so I don't see
why you would have a targetNamespace for your schema.
> Without using design time tool but rather create at runtime in C#
> code. Can you help? TIA.
XmlSchemaInference inf = new XmlSchemaInference();
XmlSchemaSet schemaSet = inf.InferSchema(XmlReader.Create("file.xml"));
Then you can process schemaSet.Schemas() or generally use the SchemaSet
as it suits you.
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/