如何使用XSD在C#? [英] How to use xsd in c#?

查看:405
本文介绍了如何使用XSD在C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的XML的。我已经使用XSD.EXE创建.xsd文件,并从XML一个cs文件。
但是我不知道什么或怎么现在访问它?
我已经看到了一些例子,但发现他们困惑。
是有一个简单的教程或某个地方的例子有人可以给我好吗?



  // ----- -------------------------------------------------- ----------------------- 
//<自动生成>
//是由工具生成该代码。
//运行时版本:4.0.30319.237
//
//对此文件的更改可能导致不正确的行为,如果
//重新生成代码将会丢失。
//< /自动生成>
// -------------------------------------------- ----------------------------------
$ b $使用的System.Xml.Serialization b:

//
//此源代码是自动生成的由XSD,版本= 4.0.30319.1。
//


///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
[System.Xml.Serialization.XmlRootAttribute(命名空间=, ISNULLABLE = FALSE)]
公共部分的类文件{

私人fileClass [] itemsField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(类,表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClass [] {项目
获得{
返回this.itemsField;
}
集合{
this.itemsField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClass {

私人串search_keywordsField;

私人fileClassPart [] partField;

私人字符串idField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串SEARCH_KEYWORDS {
获得{
返回this.search_keywordsField;
}
集合{
this.search_keywordsField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(部分,表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClassPart [] {部分
获得{
返回this.partField;
}
集合{
this.partField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串ID {
获得{
返回this.idField;
}
集合{
this.idField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPart {

私人串tcpnField;

私人字符串last_change_dateField;

私人字符串primary_part_nbrField;

私人字符串te_part_detail_urlField;

私人字符串part_statusField;

私人字符串product_codeField;

私人字符串gpl_codeField;

私人字符串gpl_descField;

私人字符串lf_comp_descField;

私人字符串lf_process_descField;

私人字符串part_descField;

私人fileClassPartImage_urls [] image_urlsField;

私人fileClassPartPart_aliasesAlias [] [] part_aliasesField;

私人fileClassPartAttributesAttr_cat [] [] attributesField;

私人fileClassPartDocInfoList [] docInfoListField;

私人字符串idField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串TCPN {
获得{
返回this.tcpnField;
}
集合{
this.tcpnField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串last_change_date {
获得{
返回this.last_change_dateField;
}
集合{
this.last_change_dateField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串primary_part_nbr {
获得{
返回this.primary_part_nbrField;
}
集合{
this.primary_part_nbrField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串te_part_detail_url {
获得{
返回this.te_part_detail_urlField;
}
集合{
this.te_part_detail_urlField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串part_status {
获得{
返回this.part_statusField;
}
集合{
this.part_statusField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串PRODUCT_CODE {
获得{
返回this.product_codeField;
}
集合{
this.product_codeField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串gpl_code {
获得{
返回this.gpl_codeField;
}
集合{
this.gpl_codeField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串gpl_desc {
获得{
返回this.gpl_descField;
}
集合{
this.gpl_descField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串lf_comp_desc {
获得{
返回this.lf_comp_descField;
}
集合{
this.lf_comp_descField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串lf_process_desc {
获得{
返回this.lf_process_descField;
}
集合{
this.lf_process_descField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串part_desc {
获得{
返回this.part_descField;
}
集合{
this.part_descField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(image_urls,表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClassPartImage_urls [] {image_urls
获得{
返回this.image_urlsField;
}
集合{
this.image_urlsField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlArrayAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute(别名,typeof运算(fileClassPartPart_aliasesAlias),表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClassPartPart_aliasesAlias [] [] {part_aliases
获得{
返回this.part_aliasesField;
}
集合{
this.part_aliasesField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlArrayAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute(attr_cat的typeof(fileClassPartAttributesAttr_cat),表= System.Xml.Schema.XmlSchemaForm.Unqualified,ISNULLABLE = FALSE)]
公共fileClassPartAttributesAttr_cat [] [] {属性
获得{
返回this.attributesField;
}
集合{
this.attributesField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(docInfoList,表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClassPartDocInfoList [] {docInfoList
获得{
返回this.docInfoListField;
}
集合{
this.docInfoListField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串ID {
获得{
返回this.idField;
}
集合{
this.idField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartImage_urls {

私人串te_primary_image_urlField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串te_primary_image_url {
获得{
返回this.te_primary_image_urlField;
}
集合{
this.te_primary_image_urlField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartPart_aliasesAlias {

私人串valueField;

///<言论/>
[System.Xml.Serialization.XmlTextAttribute()]
公共字符串值{
获得{
返回this.valueField;
}
集合{
this.valueField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartAttributesAttr_cat {

私人fileClassPartAttributesAttr_catAttr_type [] attr_typeField;

私人字符串名称字段;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(attr_type,表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClassPartAttributesAttr_catAttr_type [] {attr_type
获得{
返回this.attr_typeField;
}
集合{
this.attr_typeField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串名称{
获得{
返回this.nameField;
}
集合{
this.nameField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartAttributesAttr_catAttr_type {

私人fileClassPartAttributesAttr_catAttr_typeAttr_value [] attr_valueField;

私人fileClassPartAttributesAttr_catAttr_typeAlt_uom_attr_value [] alt_uom_attr_valueField;

私人字符串idField;

私人字符串名称字段;

私人字符串uomField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(attr_value,表= System.Xml.Schema.XmlSchemaForm.Unqualified,ISNULLABLE = TRUE)]
公共fileClassPartAttributesAttr_catAttr_typeAttr_value [] {attr_value
获得{
返回this.attr_valueField;
}
集合{
this.attr_valueField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(alt_uom_attr_value,表= System.Xml.Schema.XmlSchemaForm.Unqualified,ISNULLABLE = TRUE)]
公共fileClassPartAttributesAttr_catAttr_typeAlt_uom_attr_value [] {alt_uom_attr_value
获得{
返回this.alt_uom_attr_valueField;
}
集合{
this.alt_uom_attr_valueField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串ID {
获得{
返回this.idField;
}
集合{
this.idField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串名称{
获得{
返回this.nameField;
}
集合{
this.nameField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串计量单位{
获得{
返回this.uomField;
}
集合{
this.uomField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartAttributesAttr_catAttr_typeAttr_value {

私人串valueField;

///<言论/>
[System.Xml.Serialization.XmlTextAttribute()]
公共字符串值{
获得{
返回this.valueField;
}
集合{
this.valueField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartAttributesAttr_catAttr_typeAlt_uom_attr_value {

私人串idField;

私人字符串名称字段;

私人字符串uomField;

私人字符串valueField;

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串ID {
获得{
返回this.idField;
}
集合{
this.idField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串名称{
获得{
返回this.nameField;
}
集合{
this.nameField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlAttributeAttribute()]
公共字符串计量单位{
获得{
返回this.uomField;
}
集合{
this.uomField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlTextAttribute()]
公共字符串值{
获得{
返回this.valueField;
}
集合{
this.valueField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartDocInfoList {

私人串isDocCADFilesAvailableField;

私人fileClassPartDocInfoListDocInfo [] docInfoField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串isDocCADFilesAvailable {
获得{
返回this.isDocCADFilesAvailableField;
}
集合{
this.isDocCADFilesAvailableField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(文档信息,表= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共fileClassPartDocInfoListDocInfo [] {DOCINFO
获得{
返回this.docInfoField;
}
集合{
this.docInfoField =价值;
}
}
}

///<言论/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(XSD,4.0.30319.1)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(准则)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType =真)]
公共部分类fileClassPartDocInfoListDocInfo {

私人串docTypeField;

私人字符串docIdField;

私人字符串docRevisionField;

私人字符串docTitleField;

私人字符串docSubTypeField;

私人字符串docFileNameField;

私人字符串docFormatField;

私人字符串docSizeField;

私人字符串docLangField;

私人字符串docUrlField;

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串DOCTYPE {
获得{
返回this.docTypeField;
}
集合{
this.docTypeField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串的docId {
获得{
返回this.docIdField;
}
集合{
this.docIdField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docRevision {
获得{
返回this.docRevisionField;
}
集合{
this.docRevisionField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docTitle {
获得{
返回this.docTitleField;
}
集合{
this.docTitleField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docSubType {
获得{
返回this.docSubTypeField;
}
集合{
this.docSubTypeField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docFileName {
获得{
返回this.docFileNameField;
}
集合{
this.docFileNameField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docFormat {
获得{
返回this.docFormatField;
}
集合{
this.docFormatField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docSize {
获得{
返回this.docSizeField;
}
集合{
this.docSizeField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docLang {
获得{
返回this.docLangField;
}
集合{
this.docLangField =价值;
}
}

///<言论/>
[System.Xml.Serialization.XmlElementAttribute(表格= System.Xml.Schema.XmlSchemaForm.Unqualified)]
公共字符串docUrl {
获得{
返回this.docUrlField;
}
集合{
this.docUrlField =价值;
}
}
}


解决方案

这有点像一个人用锤子去乱跑我有这个锤子 - 有人可以告诉我一些我可以用它打?



由于用锤子例如,XSD这取决于你想用它来做什么。



例如对于如果你想创建一个XML序列化的阶层和控制XML的格式,那么你可以使用XSD.EXE生成类型传递到您的XmlSerializer的实例。



更新



这听起来像你想接收XML,然后将其反序列化类的实例,所以你可以使用它们来填充各种控制你的网站。



所以,你可以做这样的事情:

  //创建XmlSerializer的的一个实例。 
XmlSerializer的序列化=新的XmlSerializer(typeof运算(的MyType));

//读取XML。
流读取器=新的FileStream(@\MyXmlFile.xml。FileMode.Open);

//调用Deserialize方法来恢复对象的状态。
的MyType =的myType(的MyType)serializer.Deserialize(读卡器);



更新2



在你的情况,你会做这样的事情:

 文件f =(文件)serializer.Deserialize(读卡器); 

//然后你就可以用你的文件实例:
的foreach(在f.itemsField fileClass FC)
{
// ..这里$做某事b $ b}


I am new to xml's. I have used xsd.exe to create a .xsd file and a .cs file from an xml. But i don't know what or how to access it now? I have seen some example but found them confusing. Is there a simple tutorial somewhere or an example somebody could give me please?

    //------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.237
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System.Xml.Serialization;

// 
// This source code was auto-generated by xsd, Version=4.0.30319.1.
// 


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class file {

    private fileClass[] itemsField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("class", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClass[] Items {
        get {
            return this.itemsField;
        }
        set {
            this.itemsField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClass {

    private string search_keywordsField;

    private fileClassPart[] partField;

    private string idField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string search_keywords {
        get {
            return this.search_keywordsField;
        }
        set {
            this.search_keywordsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("part", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClassPart[] part {
        get {
            return this.partField;
        }
        set {
            this.partField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string id {
        get {
            return this.idField;
        }
        set {
            this.idField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPart {

    private string tcpnField;

    private string last_change_dateField;

    private string primary_part_nbrField;

    private string te_part_detail_urlField;

    private string part_statusField;

    private string product_codeField;

    private string gpl_codeField;

    private string gpl_descField;

    private string lf_comp_descField;

    private string lf_process_descField;

    private string part_descField;

    private fileClassPartImage_urls[] image_urlsField;

    private fileClassPartPart_aliasesAlias[][] part_aliasesField;

    private fileClassPartAttributesAttr_cat[][] attributesField;

    private fileClassPartDocInfoList[] docInfoListField;

    private string idField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string tcpn {
        get {
            return this.tcpnField;
        }
        set {
            this.tcpnField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string last_change_date {
        get {
            return this.last_change_dateField;
        }
        set {
            this.last_change_dateField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string primary_part_nbr {
        get {
            return this.primary_part_nbrField;
        }
        set {
            this.primary_part_nbrField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string te_part_detail_url {
        get {
            return this.te_part_detail_urlField;
        }
        set {
            this.te_part_detail_urlField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string part_status {
        get {
            return this.part_statusField;
        }
        set {
            this.part_statusField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string product_code {
        get {
            return this.product_codeField;
        }
        set {
            this.product_codeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string gpl_code {
        get {
            return this.gpl_codeField;
        }
        set {
            this.gpl_codeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string gpl_desc {
        get {
            return this.gpl_descField;
        }
        set {
            this.gpl_descField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string lf_comp_desc {
        get {
            return this.lf_comp_descField;
        }
        set {
            this.lf_comp_descField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string lf_process_desc {
        get {
            return this.lf_process_descField;
        }
        set {
            this.lf_process_descField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string part_desc {
        get {
            return this.part_descField;
        }
        set {
            this.part_descField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("image_urls", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClassPartImage_urls[] image_urls {
        get {
            return this.image_urlsField;
        }
        set {
            this.image_urlsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlArrayItemAttribute("alias", typeof(fileClassPartPart_aliasesAlias), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClassPartPart_aliasesAlias[][] part_aliases {
        get {
            return this.part_aliasesField;
        }
        set {
            this.part_aliasesField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlArrayItemAttribute("attr_cat", typeof(fileClassPartAttributesAttr_cat), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public fileClassPartAttributesAttr_cat[][] attributes {
        get {
            return this.attributesField;
        }
        set {
            this.attributesField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("docInfoList", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClassPartDocInfoList[] docInfoList {
        get {
            return this.docInfoListField;
        }
        set {
            this.docInfoListField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string id {
        get {
            return this.idField;
        }
        set {
            this.idField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartImage_urls {

    private string te_primary_image_urlField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string te_primary_image_url {
        get {
            return this.te_primary_image_urlField;
        }
        set {
            this.te_primary_image_urlField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartPart_aliasesAlias {

    private string valueField;

    /// <remarks/>
    [System.Xml.Serialization.XmlTextAttribute()]
    public string Value {
        get {
            return this.valueField;
        }
        set {
            this.valueField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartAttributesAttr_cat {

    private fileClassPartAttributesAttr_catAttr_type[] attr_typeField;

    private string nameField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("attr_type", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClassPartAttributesAttr_catAttr_type[] attr_type {
        get {
            return this.attr_typeField;
        }
        set {
            this.attr_typeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string name {
        get {
            return this.nameField;
        }
        set {
            this.nameField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartAttributesAttr_catAttr_type {

    private fileClassPartAttributesAttr_catAttr_typeAttr_value[] attr_valueField;

    private fileClassPartAttributesAttr_catAttr_typeAlt_uom_attr_value[] alt_uom_attr_valueField;

    private string idField;

    private string nameField;

    private string uomField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("attr_value", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
    public fileClassPartAttributesAttr_catAttr_typeAttr_value[] attr_value {
        get {
            return this.attr_valueField;
        }
        set {
            this.attr_valueField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("alt_uom_attr_value", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
    public fileClassPartAttributesAttr_catAttr_typeAlt_uom_attr_value[] alt_uom_attr_value {
        get {
            return this.alt_uom_attr_valueField;
        }
        set {
            this.alt_uom_attr_valueField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string id {
        get {
            return this.idField;
        }
        set {
            this.idField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string name {
        get {
            return this.nameField;
        }
        set {
            this.nameField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string uom {
        get {
            return this.uomField;
        }
        set {
            this.uomField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartAttributesAttr_catAttr_typeAttr_value {

    private string valueField;

    /// <remarks/>
    [System.Xml.Serialization.XmlTextAttribute()]
    public string Value {
        get {
            return this.valueField;
        }
        set {
            this.valueField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartAttributesAttr_catAttr_typeAlt_uom_attr_value {

    private string idField;

    private string nameField;

    private string uomField;

    private string valueField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string id {
        get {
            return this.idField;
        }
        set {
            this.idField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string name {
        get {
            return this.nameField;
        }
        set {
            this.nameField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string uom {
        get {
            return this.uomField;
        }
        set {
            this.uomField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlTextAttribute()]
    public string Value {
        get {
            return this.valueField;
        }
        set {
            this.valueField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartDocInfoList {

    private string isDocCADFilesAvailableField;

    private fileClassPartDocInfoListDocInfo[] docInfoField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string isDocCADFilesAvailable {
        get {
            return this.isDocCADFilesAvailableField;
        }
        set {
            this.isDocCADFilesAvailableField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("docInfo", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public fileClassPartDocInfoListDocInfo[] docInfo {
        get {
            return this.docInfoField;
        }
        set {
            this.docInfoField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class fileClassPartDocInfoListDocInfo {

    private string docTypeField;

    private string docIdField;

    private string docRevisionField;

    private string docTitleField;

    private string docSubTypeField;

    private string docFileNameField;

    private string docFormatField;

    private string docSizeField;

    private string docLangField;

    private string docUrlField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docType {
        get {
            return this.docTypeField;
        }
        set {
            this.docTypeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docId {
        get {
            return this.docIdField;
        }
        set {
            this.docIdField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docRevision {
        get {
            return this.docRevisionField;
        }
        set {
            this.docRevisionField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docTitle {
        get {
            return this.docTitleField;
        }
        set {
            this.docTitleField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docSubType {
        get {
            return this.docSubTypeField;
        }
        set {
            this.docSubTypeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docFileName {
        get {
            return this.docFileNameField;
        }
        set {
            this.docFileNameField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docFormat {
        get {
            return this.docFormatField;
        }
        set {
            this.docFormatField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docSize {
        get {
            return this.docSizeField;
        }
        set {
            this.docSizeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docLang {
        get {
            return this.docLangField;
        }
        set {
            this.docLangField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string docUrl {
        get {
            return this.docUrlField;
        }
        set {
            this.docUrlField = value;
        }
    }
}

解决方案

That's kind of like a man running around with a hammer going "I have this hammer - can someone tell me something I can hit with it?".

As with the hammer example, with XSD it depends what you want to use it for.

For example, if you want to create a XML-serializable class and control the format of the xml then you can use xsd.exe to generate the types to pass into your XmlSerializer instance.

UPDATE

It sounds like you want to receive XML and then deserialize it to class instances so you can use them to populate various controls on your website.

So you can do something like this:

// Create an instance of the XmlSerializer.
XmlSerializer serializer = new XmlSerializer(typeof(MyType));

// Read the xml.
Stream reader= new FileStream(@".\MyXmlFile.xml", FileMode.Open);

// Call the Deserialize method to restore the object's state.
MyType myType = (MyType) serializer.Deserialize(reader);

UPDATE 2

In your case you would do something like:

file f = (file) serializer.Deserialize(reader);

// Then you can use your "file" instance:
foreach (fileClass fc in f.itemsField)
{
    //.. Do something here
}

这篇关于如何使用XSD在C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆