C # Use the xsd.exe tool to operate XML. For example, use XML to generate an xsd file.

Source: Internet
Author: User

First, find the Visual Studio 2005 command prompt in the Start Menu.

Enter the directory where the file is located, for example,-> D:

Operation example
The following command generates an XML schema from myFile. xdr and saves it to the current directory.

Xsd MyFile. xdr
The following command generates an xml schema from myFile. XML and saves it to the specified directory.

Xsd myFile. xml /Outputdir: myOutputDir
The following command generates a DataSet that corresponds to the specified architecture in C #, and saves it as XSDSchemaFile. cs in the current directory.

Xsd/dataset/language: C # XSDSchemaFile. xsd
The following command generates an XML schema for all types in assembly myAssembly. dll and saves them as schema0.xsd in the current directory.

Xsd MyAssembly. dll 

 

 

Others: bytes :------------------------------------------------------------------------------------------------------------------

XML schema definition tools generate XML schema or Common Language Runtime library classes from XDR, XML, and XSD files, or from classes in the Runtime Library set.

Xsd file. xdr [/outputdir: directory]
Xsd file. xml [/outputdir: directory]
Xsd file. xsd {/classes |/dataset} [/element: element]
[/Language: language] [/namespace: namespace]
[/Outputdir: directory] [URI: uri]
Xsd {file. dll | file.exe} [/outputdir: directory] [/type: typename [...]
Parameter description
File. extension: the input file to be converted. You must specify extension as one of the following:. xdr,. xml,. xsd,. dll, or. exe.
If an XDR architecture file (. xdr extension) is specified, Xsd.exe converts the XDR architecture to the XSD architecture. The output file has the same name as the XDR architecture, but the extension is. xsd.

If an XML file (. xml extension) is specified, Xsd.exe exports the schema from the file and generates an XSD Schema. The output file has the same name as the XML file, but the extension is. xsd.

If an XML schema file (. xsd extension) is specified, Xsd.exe generates source code for the runtime object corresponding to the XML schema.

If you specify a library file (.exe or. dll extension), Xsd.exe generates the architecture for one or more types of the Assembly. You can use the/type option to specify the type of the generated architecture. The output architecture is named schema0.xsd and schema1.xsd. Xsd.exe generates Multiple Architectures only when the Custom Attributes of XMLRoot are used to specify the namespace for a given type.

General options
Option description
/H [elp] displays the command syntax and options of this tool.
/O [utputdir]: directory specifies the directory of the output file. This parameter can only appear once. The current directory is used by default.
/? Displays the command syntax and options of this tool.

XSD File Options
Only one of the following options must be specified for the xsd file.

Option description
/C [lasses] generates the class corresponding to the specified architecture. To read XML data into an object, use the System. XML. Serialization. XMLSerializer. Deserializer method.
/D [ataset] generates a class derived from DataSet, which corresponds to the specified architecture. To read XML Data into a derived class, use the System. Data. DataSet. ReadXml method.

You can also specify any of the following options for the. xsd file.

Option description
/E [lement]: element specifies the element for which code is generated in the architecture. By default, all elements are entered. You can specify this parameter multiple times.
/L [anguage]: language indicates the programming language to be used. Select from CS (default), VB, or JS. You can also specify a fully qualified name for the class implementing System. CodeDom. Compiler. CodeDomProvider.
/N [amespace]: namespace specifies the runtime namespace for the generated type. The default namespace is Schemas.
/U [ri]: uri specifies the URI for the element of the Code to be generated in the architecture. This URI (if any) applies to all elements specified by the/element option.

DLL and EXE file options
Option description
/T [ype]: typename specifies the name of the type for which the architecture is to be created. You can specify multiple type parameters. If typename does not specify a life-Name Space, xsd.exe matches all types in the Assembly with the specified type. If typename specifies a namespace, only that type is matched. If typename ends with a star character (*), this tool matches all types starting with the string before. If the/type scheme is omitted, xsd.exe is used to generate the architecture of all types in the Assembly.

Remarks
Xsd.exe performs the following operations:

XDR to XSD
Use a simplified XML data architecture file to generate an XML architecture. XDR is an earlier XML-based architecture format.
XML to XSD
Use an XML file to generate an XML schema.
XSD to DataSet
Use the XSD Schema file to generate the DataSet class of the Common Language Runtime Library. The generated class provides a complex object model for rule XML data.
XSD to class
Use the XSD Schema file to generate the runtime class. The generated class can be used with System. XML. Serialization. XMLSerializer to read and write XML Code following the architecture.
Class to XSD
Generate the XML schema using one or more types in the Runtime Library Assembly file. The generated schema definition is in the XML format used by System. XML. Serialization. XMLSerializer.
Xsd.exe only allows operations to follow the XML schema defined by the XML schema (XSD) language proposed by the WWW Federation (W3C. For more information about XML schema definition proposals or XML standards, see http://w3c.org. 

 

When trying

 

From: http://blog.sina.com.cn/s/blog_46ec15280100cos0.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.