Domanda

I've seen a technique of reading and writing XML to disk using only C# class names an no obvious Attributes[].

What is this called, and how do I apply it to a data set that looks like this:

<?xml version="1.0"?>   
<feedback>  
  <report_metadata> 
    <org_name>Yahoo! Inc.</org_name>    
    <email>postmaster@dmarc.yahoo.com</email>   
    <report_id>1340012067.929728</report_id>    
    <date_range>    
      <begin>1339891200</begin> 
      <end>1339977599 </end>    
    </date_range>   
  </report_metadata>    
  <policy_published>    
    <domain>company.com</domain>    
    <adkim>r</adkim>    
    <aspf>r</aspf>  
    <p>none</p> 
    <pct>100</pct>  
  </policy_published>   
  <record>  
    <row>   
      <source_ip>123.18.181.64</source_ip>  
      <count>1</count>  
      <policy_evaluated>    
        <disposition>none</disposition> 
        <dkim>fail</dkim>   
        <spf>fail</spf> 
      </policy_evaluated>   
    </row>  
    <identifiers>   
      <header_from>company.com</header_from>    
    </identifiers>  
    <auth_results>  
      <dkim>    
        <domain>company.com</domain>    
        <result>neutral</result>    
      </dkim>   
      <spf> 
        <domain>company.com</domain>    
        <result>softfail</result>   
      </spf>    
    </auth_results> 
  </record> 
</feedback> 

Update

I was able to convert that XML to type safe C#:

I ran this command to get the schema

C:\Temp>xsd test.xml  /c /language:cs /out:c:\temp
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'c:\temp\test.xsd'.

And then ran this command to get the CS file

C:\Temp>xsd test.xsd /c /language:cs
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\Temp\test.cs'.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.544
//
//     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 feedback
{

    private object[] itemsField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("policy_published", typeof(feedbackPolicy_published), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlElementAttribute("record", typeof(feedbackRecord), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlElementAttribute("report_metadata", typeof(feedbackReport_metadata), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public object[] 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 feedbackPolicy_published
{

    private string domainField;

    private string adkimField;

    private string aspfField;

    private string pField;

    private string pctField;

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

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

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string pct
    {
        get
        {
            return this.pctField;
        }
        set
        {
            this.pctField = 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 feedbackRecord
{

    private feedbackRecordRow[] rowField;

    private feedbackRecordIdentifiers[] identifiersField;

    private feedbackRecordAuth_results[] auth_resultsField;

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("auth_results", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackRecordAuth_results[] auth_results
    {
        get
        {
            return this.auth_resultsField;
        }
        set
        {
            this.auth_resultsField = 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 feedbackRecordRow
{

    private string source_ipField;

    private string countField;

    private feedbackRecordRowPolicy_evaluated[] policy_evaluatedField;

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("policy_evaluated", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackRecordRowPolicy_evaluated[] policy_evaluated
    {
        get
        {
            return this.policy_evaluatedField;
        }
        set
        {
            this.policy_evaluatedField = 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 feedbackRecordRowPolicy_evaluated
{

    private string dispositionField;

    private string dkimField;

    private string spfField;

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string spf
    {
        get
        {
            return this.spfField;
        }
        set
        {
            this.spfField = 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 feedbackRecordIdentifiers
{

    private string header_fromField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string header_from
    {
        get
        {
            return this.header_fromField;
        }
        set
        {
            this.header_fromField = 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 feedbackRecordAuth_results
{

    private feedbackRecordAuth_resultsDkim[] dkimField;

    private feedbackRecordAuth_resultsSpf[] spfField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("spf", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackRecordAuth_resultsSpf[] spf
    {
        get
        {
            return this.spfField;
        }
        set
        {
            this.spfField = 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 feedbackRecordAuth_resultsDkim
{

    private string domainField;

    private string resultField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string result
    {
        get
        {
            return this.resultField;
        }
        set
        {
            this.resultField = 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 feedbackRecordAuth_resultsSpf
{

    private string domainField;

    private string resultField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string result
    {
        get
        {
            return this.resultField;
        }
        set
        {
            this.resultField = 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 feedbackReport_metadata
{

    private string org_nameField;

    private string emailField;

    private string report_idField;

    private feedbackReport_metadataDate_range[] date_rangeField;

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

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("date_range", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackReport_metadataDate_range[] date_range
    {
        get
        {
            return this.date_rangeField;
        }
        set
        {
            this.date_rangeField = 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 feedbackReport_metadataDate_range
{

    private string beginField;

    private string endField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string end
    {
        get
        {
            return this.endField;
        }
        set
        {
            this.endField = value;
        }
    }
}
È stato utile?

Soluzione 5

Here is the XML

I ran this command to get the schema

C:\Temp>xsd test.xml  /c /language:cs /out:c:\temp
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'c:\temp\test.xsd'.

And then ran this command to get the CS file

C:\Temp>xsd test.xsd /c /language:cs
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\Temp\test.cs'.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.544
//
//     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 feedback
{

    private object[] itemsField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("policy_published", typeof(feedbackPolicy_published), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlElementAttribute("record", typeof(feedbackRecord), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlElementAttribute("report_metadata", typeof(feedbackReport_metadata), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public object[] 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 feedbackPolicy_published
{

    private string domainField;

    private string adkimField;

    private string aspfField;

    private string pField;

    private string pctField;

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

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

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string pct
    {
        get
        {
            return this.pctField;
        }
        set
        {
            this.pctField = 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 feedbackRecord
{

    private feedbackRecordRow[] rowField;

    private feedbackRecordIdentifiers[] identifiersField;

    private feedbackRecordAuth_results[] auth_resultsField;

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("auth_results", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackRecordAuth_results[] auth_results
    {
        get
        {
            return this.auth_resultsField;
        }
        set
        {
            this.auth_resultsField = 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 feedbackRecordRow
{

    private string source_ipField;

    private string countField;

    private feedbackRecordRowPolicy_evaluated[] policy_evaluatedField;

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("policy_evaluated", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackRecordRowPolicy_evaluated[] policy_evaluated
    {
        get
        {
            return this.policy_evaluatedField;
        }
        set
        {
            this.policy_evaluatedField = 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 feedbackRecordRowPolicy_evaluated
{

    private string dispositionField;

    private string dkimField;

    private string spfField;

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string spf
    {
        get
        {
            return this.spfField;
        }
        set
        {
            this.spfField = 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 feedbackRecordIdentifiers
{

    private string header_fromField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string header_from
    {
        get
        {
            return this.header_fromField;
        }
        set
        {
            this.header_fromField = 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 feedbackRecordAuth_results
{

    private feedbackRecordAuth_resultsDkim[] dkimField;

    private feedbackRecordAuth_resultsSpf[] spfField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("spf", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackRecordAuth_resultsSpf[] spf
    {
        get
        {
            return this.spfField;
        }
        set
        {
            this.spfField = 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 feedbackRecordAuth_resultsDkim
{

    private string domainField;

    private string resultField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string result
    {
        get
        {
            return this.resultField;
        }
        set
        {
            this.resultField = 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 feedbackRecordAuth_resultsSpf
{

    private string domainField;

    private string resultField;

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string result
    {
        get
        {
            return this.resultField;
        }
        set
        {
            this.resultField = 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 feedbackReport_metadata
{

    private string org_nameField;

    private string emailField;

    private string report_idField;

    private feedbackReport_metadataDate_range[] date_rangeField;

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

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

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

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("date_range", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public feedbackReport_metadataDate_range[] date_range
    {
        get
        {
            return this.date_rangeField;
        }
        set
        {
            this.date_rangeField = 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 feedbackReport_metadataDate_range
{

    private string beginField;

    private string endField;

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

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

Altri suggerimenti

You could do this with the XMLSerializer class.

Have a look here: MSDN on XMLSerializer

And here is a description on what to do: How to read and write XML in C#

But, it is far more comfortable if you write some classes representing the XML in C# and write the ReadXML and WriteXML Methods... or use attributes in the first place.

Here you have a small article how that will work: CodeProject: How to use XMLSerializer

Here you not write what is your requirement.you can try using System.Xml

Here is small code to perform reading XML file

  XmlDocument doc = new XmlDocument();
  doc.Load("Test.xml");
  XmlElement root = doc.DocumentElement;
//Preform your read and write operation here
 doc.Save("Test.xml");

Common ways to read XML using C# are LINQ to XML, XmlDocument, and XmlReader.

This article details the performance of each way. In short, XmlReader has better performance across the board. However, LINQ to XML has better performance with very small XML documents (with one child node).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top