Note that there are some explanatory texts on larger screens.

plurals
  1. POHow use Class generated by XSD
    primarykey
    data
    text
    <p>I have this xml file :</p> <pre><code>&lt;?xml version="1.0" encoding="us-ascii"?&gt; &lt;body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;header&gt;&lt;user&gt;BOBBY&lt;/user&gt;&lt;/header&gt; &lt;in&gt; &lt;customer&gt;0123456789&lt;/customer&gt; &lt;/in&gt; &lt;out&gt; &lt;cmd&gt; &lt;productid&gt;&lt;/productid&gt; &lt;price&gt;&lt;/price&gt; &lt;date&gt;&lt;/date&gt; &lt;state&gt;&lt;/state&gt; &lt;type&gt;&lt;/type&gt; &lt;/cmd&gt; &lt;cmd&gt; &lt;productid&gt;&lt;/productid&gt; &lt;price&gt;&lt;/price&gt; &lt;date&gt;&lt;/date&gt; &lt;state&gt;&lt;/state&gt; &lt;type&gt;&lt;/type&gt; &lt;/cmd&gt; &lt;/out&gt; &lt;state&gt; &lt;code&gt;&lt;/code&gt; &lt;desc&gt;&lt;/desc&gt; &lt;/state&gt; &lt;/body&gt; </code></pre> <p>And Xsd.Exe generate this class :</p> <pre><code>namespace System.autoGenerated { using System.Xml.Serialization; /// &lt;remarks/&gt; [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")] [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 body : object, System.ComponentModel.INotifyPropertyChanged { /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute("header", typeof(bodyHeader), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute("in", typeof(bodyIN), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute("out", typeof(bodyOut), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute("state", typeof(bodyState), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public object[] Items; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } /// &lt;remarks/&gt; [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class bodyHeader : object, System.ComponentModel.INotifyPropertyChanged { /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string user; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } /// &lt;remarks/&gt; [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class bodyIN : object, System.ComponentModel.INotifyPropertyChanged { /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string customer; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } /// &lt;remarks/&gt; [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class bodyOut : object, System.ComponentModel.INotifyPropertyChanged { /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute("cmd", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public bodyOutCmd[] cmd; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } /// &lt;remarks/&gt; [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class bodyOutCmd : object, System.ComponentModel.INotifyPropertyChanged { /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string productid; /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string price; /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string date; /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string state; /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string type; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } /// &lt;remarks/&gt; [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class bodyState : object, System.ComponentModel.INotifyPropertyChanged { /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string code; /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string desc; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } } </code></pre> <p>How can i use this file? I don't understand how to use it in an extend class for use this partial class.</p> <p>My goal is to serialie and deserialize and object. ----------------------------------UPDATE----------------------------</p> <p>I've already create this testing code : using System; using DAL.XML.PDD.PDDORDM001; using System.Xml.Serialization; using System.IO;</p> <pre><code>namespace Tests { class Serialize { public static void Main() { Console.WriteLine("Go..."); XmlSerializer serializer = new XmlSerializer(typeof(body)); TextWriter writer = new StreamWriter(@"c:\file.xml"); body test = null; serializer.Serialize(writer, test); writer.Close(); } } } </code></pre> <p>But it give me this result :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload