Open the vs command window,
Enter the command: XSD file. xml [/outputdir: Directory] [/parameters: file. xml]
Example:
Appendix 1: categories. xml
<? XML Version = " 1.0 " Encoding = " UTF-8 " ?> < Categories > < Category > < ID > 2 </ ID > < Visible > True </ Visible > < Title > News Classification </ Title > < Description > </ Description > < Parentid > </ Parentid > </ Category > < Category > < ID > 0001 </ ID > < Visible > True </ Visible > < Title > News Classification 1 </ Title > < Description > Test 1 ~ </ Description > < Parentid > 2 </ Parentid > </ Category > < Category > < ID > 0002 </ ID > < Visible > True </ Visible > < Title > News classification II </ Title > < Description > Test 2 ~ </ Description > < Parentid > 2 </ Parentid > </ Category > </ Categories >
Appendix 2: converted categories. XSD
Note: After conversion, the file content may be slightly modified. The type attribute of the element in the converted file is "XS: string" by default"
Here, change the type attribute of visible to"Xs: Boolean"
<? XML Version = " 1.0 " Encoding = " UTF-8 " ?> < Xs: Schema ID = " Categories " Xmlns = "" Xmlns: XS = " Http://www.w3.org/2001/XMLSchema " Xmlns: msdata = "URN: Schemas-Microsoft-com: XML-msdata " > < Xs: Element Name = " Categories " Msdata: isdataset = " True " Msdata: locale = " En-US " > < Xs: complextype > < Xs: Choice Minoccurs = " 0 " Maxoccurs = " Unbounded " > < Xs: Element Name = " Category " > < Xs: complextype > < Xs: Sequence > < Xs: Element Name = " ID " Type = " Xs: String " Minoccurs = " 0 " /> < Xs: Element Name = "Visible " Type = " Xs: Boolean " Minoccurs = " 0 " /> <! -- Note: --> < Xs: Element Name = " Title "Type = " Xs: String " Minoccurs = " 0 " /> < Xs: Element Name = " Description " Type = " Xs: String " Minoccurs = "0 " /> < Xs: Element Name = " Parentid " Type = " Xs: String " Minoccurs = " 0 " /> </ Xs: Sequence > </ Xs: complextype > </ Xs: Element > </ Xs: Choice > </ Xs: complextype > </ Xs: Element > </ Xs: Schema >
---------
Note: If the XML file is not automatically generated, you can also use "create XML schema file" to create a new XSD file, as shown below:
<? XML Version = " 1.0 " Encoding = " UTF-8 " ?> < Xs: Schema ID = " XMLSCHEMA "
Targetnamespace =" Http://tempuri.org/XMLSchema.xsd" <! -- This sentenceCodeNeed to be deleted. Otherwise, XML data cannot be read through dataset. Why? Remove to display -->
Elementformdefault = " Qualified " Xmlns = " Http://tempuri.org/XMLSchema.xsd " Xmlns: mstns = "Http://tempuri.org/XMLSchema.xsd " Xmlns: XS = " Http://www.w3.org/2001/XMLSchema " > </ Xs: Schema >