XmlSerializer.Deserialize XmlSerializer.Deserialize XmlSerializer.Deserialize XmlSerializer.Deserialize Method

Definition

Deserialisiert ein XML-Dokument.Deserializes an XML document.

Überlädt

Deserialize(Stream) Deserialize(Stream) Deserialize(Stream)

Deserialisiert das im angegebenen Stream enthaltene XML-Dokument.Deserializes the XML document contained by the specified Stream.

Deserialize(TextReader) Deserialize(TextReader) Deserialize(TextReader)

Deserialisiert das im angegebenen TextReader enthaltene XML-Dokument.Deserializes the XML document contained by the specified TextReader.

Deserialize(XmlSerializationReader) Deserialize(XmlSerializationReader) Deserialize(XmlSerializationReader) Deserialize(XmlSerializationReader)

Deserialisiert das im angegebenen XmlSerializationReader enthaltene XML-Dokument.Deserializes the XML document contained by the specified XmlSerializationReader.

Deserialize(XmlReader) Deserialize(XmlReader) Deserialize(XmlReader)

Deserialisiert das im angegebenen XmlReader enthaltene XML-Dokument.Deserializes the XML document contained by the specified XmlReader.

Deserialize(XmlReader, String) Deserialize(XmlReader, String) Deserialize(XmlReader, String)

Deserialisiert das im angegebenen XmlReader enthaltene XML-Dokument anhand des angegebenen Codierungsstils.Deserializes the XML document contained by the specified XmlReader and encoding style.

Deserialize(XmlReader, XmlDeserializationEvents) Deserialize(XmlReader, XmlDeserializationEvents) Deserialize(XmlReader, XmlDeserializationEvents)

Deserialisiert ein im XmlReader enthaltenes XML-Dokument und ermöglicht das Überschreiben der Ereignisse, die während der Deserialisierung eintreten.Deserializes an XML document contained by the specified XmlReader and allows the overriding of events that occur during deserialization.

Deserialize(XmlReader, String, XmlDeserializationEvents) Deserialize(XmlReader, String, XmlDeserializationEvents) Deserialize(XmlReader, String, XmlDeserializationEvents)

Deserialisiert das Objekt mit den im angegebenen XmlReader enthaltenen Daten.Deserializes the object using the data contained by the specified XmlReader.

Deserialize(Stream) Deserialize(Stream) Deserialize(Stream)

Deserialisiert das im angegebenen Stream enthaltene XML-Dokument.Deserializes the XML document contained by the specified Stream.

public:
 System::Object ^ Deserialize(System::IO::Stream ^ stream);
public object Deserialize (System.IO.Stream stream);
member this.Deserialize : System.IO.Stream -> obj

Parameter

stream
Stream Stream Stream Stream

Der Stream mit dem zu deserialisierenden XML-Dokument.The Stream that contains the XML document to deserialize.

Gibt zurück

Das Object, das deserialisiert wird.The Object being deserialized.

Beispiele

Im folgenden Beispiel wird deserialisiert ein Objekt mit einem Stream Objekt.The following example deserializes an object using a Stream object.

#using <System.Xml.dll>
#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml::Serialization;

// This is the class that will be deserialized.
public ref class OrderedItem
{
public:

    [XmlElement(Namespace="http://www.cpandl.com")]
    String^ ItemName;

    [XmlElement(Namespace="http://www.cpandl.com")]
    String^ Description;

    [XmlElement(Namespace="http://www.cohowinery.com")]
    Decimal UnitPrice;

    [XmlElement(Namespace="http://www.cpandl.com")]
    int Quantity;

    [XmlElement(Namespace="http://www.cohowinery.com")]
    Decimal LineTotal;

    // A custom method used to calculate price per item.
    void Calculate()
    {
        LineTotal = UnitPrice * Quantity;
    }
};

void DeserializeObject(String^ filename)
{
	Console::WriteLine("Reading with Stream");

	// Create an instance of the XmlSerializer.
	XmlSerializer^ serializer = gcnew XmlSerializer(OrderedItem::typeid);

	// Declare an object variable of the type to be deserialized.
	OrderedItem^ i;
	
	// Reading the XML document requires a FileStream.
	Stream^ reader = gcnew FileStream(filename, FileMode::Open);

	try
	{
		// Call the Deserialize method to restore the object's state.
		i = dynamic_cast<OrderedItem^>(serializer->Deserialize(reader));
	}
	finally
	{
		delete reader;
	}

	// Write out the properties of the object.
	Console::Write("{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal);
}

int main()
{
    // Read a purchase order.
    DeserializeObject( "simple.xml" );
}
using System;
using System.IO;
using System.Xml.Serialization;

// This is the class that will be deserialized.
public class OrderedItem
{
    [XmlElement(Namespace = "http://www.cpandl.com")]
    public string ItemName;
    [XmlElement(Namespace = "http://www.cpandl.com")]
    public string Description;
    [XmlElement(Namespace="http://www.cohowinery.com")]
    public decimal UnitPrice;
    [XmlElement(Namespace = "http://www.cpandl.com")]
    public int Quantity;
    [XmlElement(Namespace="http://www.cohowinery.com")]
    public decimal LineTotal;
    // A custom method used to calculate price per item.
    public void Calculate()
    {
        LineTotal = UnitPrice * Quantity;
    }
}
 
public class Test
{
    public static void Main()
    {
        Test t = new Test();
        // Read a purchase order.
        t.DeserializeObject("simple.xml");
    }

    private void DeserializeObject(string filename)
    {   
        Console.WriteLine("Reading with Stream");
        // Create an instance of the XmlSerializer.
        XmlSerializer serializer = 
        new XmlSerializer(typeof(OrderedItem));
          
        // Declare an object variable of the type to be deserialized.
        OrderedItem i;

        using (Stream reader = new FileStream(filename, FileMode.Open))
        {
            // Call the Deserialize method to restore the object's state.
            i = (OrderedItem)serializer.Deserialize(reader);          
        }

        // Write out the properties of the object.
        Console.Write(
        i.ItemName + "\t" +
        i.Description + "\t" +
        i.UnitPrice + "\t" +
        i.Quantity + "\t" +
        i.LineTotal);
    }
}

Imports System
Imports System.IO
Imports System.Xml.Serialization
Imports Microsoft.VisualBasic


' This is the class that will be deserialized.
Public Class OrderedItem
    <XmlElement(Namespace := "http://www.cpandl.com")> _
    Public ItemName As String

    <XmlElement(Namespace := "http://www.cpandl.com")> _
    Public Description As String
    
    <XmlElement(Namespace := "http://www.cohowinery.com")> _
    Public UnitPrice As Decimal
    
    <XmlElement(Namespace := "http://www.cpandl.com")> _
    Public Quantity As Integer
    
    <XmlElement(Namespace := "http://www.cohowinery.com")> _
    Public LineTotal As Decimal
    
    'A custom method used to calculate price per item.
    Public Sub Calculate()
        LineTotal = UnitPrice * Quantity
    End Sub
End Class

Public Class Test
    
    Public Shared Sub Main()
        Dim t As New Test()
        ' Read a purchase order.
        t.DeserializeObject("simple.xml")
    End Sub
        
    Private Sub DeserializeObject(ByVal filename As String)
        Console.WriteLine("Reading with Stream")
        ' Create an instance of the XmlSerializer.
        Dim serializer As New XmlSerializer(GetType(OrderedItem))       
        
        ' Declare an object variable of the type to be deserialized.
        Dim i As OrderedItem

        Using reader As New Filestream(filename, FileMode.Open)

            ' Call the Deserialize method to restore the object's state.
            i = CType(serializer.Deserialize(reader), OrderedItem)
        End Using

        ' Write out the properties of the object.
        Console.Write(i.ItemName & ControlChars.Tab & _
                      i.Description & ControlChars.Tab & _
                      i.UnitPrice & ControlChars.Tab & _
                      i.Quantity & ControlChars.Tab & _
                      i.LineTotal)
    End Sub
End Class

<?xml version="1.0"?>
 <OrderedItem xmlns:inventory="http://www.cpandl.com" xmlns:money="http://www.cohowinery.com">
   <inventory:ItemName>Widget</inventory:ItemName>
   <inventory:Description>Regular Widget</inventory:Description>
   <money:UnitPrice>2.3</money:UnitPrice>
   <inventory:Quantity>10</inventory:Quantity>
   <money:LineTotal>23</money:LineTotal>
 </OrderedItem>

Hinweise

Deserialisierung wird das Lesen eines XML-Dokuments, und erstellen ein Objekt, das stark auf die XML-Schema (XSD) des Dokuments typisiert ist.Deserialization is the process of reading an XML document and constructing an object that is strongly typed to the XML Schema (XSD) of the document.

Vor der Deserialisierung ein XmlSerializer muss erstellt werden, mit dem Typ des Objekts, das deserialisiert wird.Before deserializing, an XmlSerializer must be constructed using the type of the object that is being deserialized.

Verwenden der stream Parameter zur Angabe eines Objekts, das von abgeleitet ist die Stream -Klasse, die zum Schreiben in Streams vorgesehen ist.Use the stream parameter to specify an object that derives from the Stream class, which is designed to write to streams. Abgeleitete Klassen die Stream Klasse enthalten:Classes that derive from the Stream class include:

Hinweis

Die XmlSerializer kann nicht deserialisiert werden die folgenden: Arrays von ArrayList und Arrays von List<T>.The XmlSerializer cannot deserialize the following: arrays of ArrayList and arrays of List<T>.

Siehe auch

Deserialize(TextReader) Deserialize(TextReader) Deserialize(TextReader)

Deserialisiert das im angegebenen TextReader enthaltene XML-Dokument.Deserializes the XML document contained by the specified TextReader.

public:
 System::Object ^ Deserialize(System::IO::TextReader ^ textReader);
public object Deserialize (System.IO.TextReader textReader);
member this.Deserialize : System.IO.TextReader -> obj

Parameter

textReader
TextReader TextReader TextReader TextReader

Der TextReader mit dem zu deserialisierenden XML-Dokument.The TextReader that contains the XML document to deserialize.

Gibt zurück

Das Object, das deserialisiert wird.The Object being deserialized.

Ausnahmen

Bei der Deserialisierung ist ein Fehler aufgetreten.An error occurred during deserialization. Die ursprüngliche Ausnahme ist mithilfe der InnerException-Eigenschaft verfügbar.The original exception is available using the InnerException property.

Beispiele

Im folgenden Beispiel wird deserialisiert ein Objekt mit einem TextReader Objekt.The following example deserializes an object using a TextReader object.

#using <System.Xml.dll>
#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Xml::Serialization;

// This is the class that will be deserialized.
public ref class OrderedItem
{
public:
    String^ ItemName;
    String^ Description;
    Decimal UnitPrice;
    int Quantity;
    Decimal LineTotal;

    // A custom method used to calculate price per item.
    void Calculate()
    {
        LineTotal = UnitPrice * Quantity;
    }
};

void DeserializeObject( String^ filename )
{
    Console::WriteLine( "Reading with TextReader" );

    // Create an instance of the XmlSerializer specifying type.
    XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid );

    /* Create a TextReader to read the file. Specify an
       Encoding to use. */
    TextReader^ reader = gcnew StreamReader( filename,Encoding::Unicode );

    // Declare an object variable of the type to be deserialized.
    OrderedItem^ i;

    // Use the Deserialize method to restore the object's state.
    i = dynamic_cast<OrderedItem^>(serializer->Deserialize( reader ));

    // Write out the properties of the object.
    Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal );
}

int main()
{
    // Read a purchase order.
    DeserializeObject( "simple.xml" );
}
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;

// This is the class that will be deserialized.
public class OrderedItem
{
    [XmlElement(Namespace = "http://www.cpandl.com")]
    public string ItemName;
    [XmlElement(Namespace = "http://www.cpandl.com")]
    public string Description;
    [XmlElement(Namespace = "http://www.cohowinery.com")]
    public decimal UnitPrice;
    [XmlElement(Namespace = "http://www.cpandl.com")]
    public int Quantity;
    [XmlElement(Namespace = "http://www.cohowinery.com")]
    public decimal LineTotal;
    // A custom method used to calculate price per item.
    public void Calculate()
    {
        LineTotal = UnitPrice * Quantity;
    }
}
 
public class Test
{
   public static void Main()
    {
        Test t = new Test();
        // Read a purchase order.
        t.DeserializeObject("simple.xml");
    }

    private void DeserializeObject(string filename)
    {   
        Console.WriteLine("Reading with TextReader");

        // Create an instance of the XmlSerializer specifying type.
        XmlSerializer serializer = 
        new XmlSerializer(typeof(OrderedItem));

        // Create a TextReader to read the file. 
        FileStream fs = new FileStream(filename, FileMode.OpenOrCreate);
        TextReader reader = new StreamReader(fs);
      
        // Declare an object variable of the type to be deserialized.
        OrderedItem i;

        // Use the Deserialize method to restore the object's state.
        i = (OrderedItem) serializer.Deserialize(reader);

        // Write out the properties of the object.
        Console.Write(
            i.ItemName + "\t" +
            i.Description + "\t" +
            i.UnitPrice + "\t" +
            i.Quantity + "\t" +
            i.LineTotal);
    }
}
Imports System
Imports System.IO
Imports System.Text
Imports System.Xml.Serialization
Imports Microsoft.VisualBasic

' This is the class that will be deserialized.
Public Class OrderedItem
    <XmlElement(Namespace := "http://www.cpandl.com")> _
    Public ItemName As String

    <XmlElement(Namespace := "http://www.cpandl.com")> _
    Public Description As String
    
    <XmlElement(Namespace := "http://www.cohowinery.com")> _
    Public UnitPrice As Decimal
    
    <XmlElement(Namespace := "http://www.cpandl.com")> _
    Public Quantity As Integer
    
    <XmlElement(Namespace := "http://www.cohowinery.com")> _
    Public LineTotal As Decimal
    ' A custom method used to calculate price per item.
    Public Sub Calculate()
        LineTotal = UnitPrice * Quantity
    End Sub
End Class
Public Class Test
    
    Public Shared Sub Main()
        Dim t As New Test()
        ' Read a purchase order.
        t.DeserializeObject("simple.xml")
    End Sub
    
    Private Sub DeserializeObject(filename As String)
        Console.WriteLine("Reading with TextReader")
        
        ' Create an instance of the XmlSerializer specifying type.
        Dim serializer As New XmlSerializer(GetType(OrderedItem))
        
        ' Create a TextReader to read the file. 
        Dim fs as New FileStream(filename, FileMode.OpenOrCreate)
        Dim reader As New StreamReader(fs)
        
        ' Declare an object variable of the type to be deserialized.
        Dim i As OrderedItem
        
        ' Use the Deserialize method to restore the object's state.
        i = CType(serializer.Deserialize(reader), OrderedItem)
        
        ' Write out the properties of the object.
        Console.Write(i.ItemName & ControlChars.Tab & _
                      i.Description & ControlChars.Tab & _
                      i.UnitPrice & ControlChars.Tab & _
                      i.Quantity & ControlChars.Tab & _
                      i.LineTotal)
    End Sub
End Class

Hinweise

Deserialisierung wird das von einer Instanz von einem XML-Dokument zu lesen und erstellen ein Objekt, das stark auf die XML-Schema (XSD) des Dokuments typisiert ist.Deserialization is the process of reading an instance of an XML document and constructing an object that is strongly typed to the XML Schema (XSD) of the document.

Vor der Deserialisierung ein XmlSerializer muss erstellt werden, mit dem Typ des Objekts, das deserialisiert wird.Before deserializing, an XmlSerializer must be constructed using the type of the object that is being deserialized.

Klassen, die von erben TextReader enthalten StringReader und StreamReader.Classes that inherit from TextReader include StringReader and StreamReader. Bei Verwendung einer StreamReader um ein Objekt zu deserialisieren, müssen Sie erstellen die StreamReader durch eine entsprechende Encoding.If you are using a StreamReader to deserialize an object, you must construct the StreamReader with an appropriate Encoding. Durch das XML-Dokument angegebene Codierung wird ignoriert.The encoding specified by the XML document is ignored.

Hinweis

Verwenden, um die durch das XML-Dokument angegebene Codierung zu verwenden, die Deserialize -Überladung mit einem XmlReader stattdessen.To use the encoding specified by the XML document, use the Deserialize overload that takes an XmlReader instead. Die XmlReader erkennt automatisch, und der angegebenen Codierung von XML-Dokument.The XmlReader automatically detects and uses the encoding specified by the XML document.

Hinweis

Die XmlSerializer kann nicht deserialisiert werden die folgenden: Arrays von ArrayList und Arrays von List<T>.The XmlSerializer cannot deserialize the following: arrays of ArrayList and arrays of List<T>.

Siehe auch

Deserialize(XmlSerializationReader) Deserialize(XmlSerializationReader) Deserialize(XmlSerializationReader) Deserialize(XmlSerializationReader)

Deserialisiert das im angegebenen XmlSerializationReader enthaltene XML-Dokument.Deserializes the XML document contained by the specified XmlSerializationReader.

protected:
 virtual System::Object ^ Deserialize(System::Xml::Serialization::XmlSerializationReader ^ reader);
protected virtual object Deserialize (System.Xml.Serialization.XmlSerializationReader reader);
abstract member Deserialize : System.Xml.Serialization.XmlSerializationReader -> obj
override this.Deserialize : System.Xml.Serialization.XmlSerializationReader -> obj
Protected Overridable Function Deserialize (reader As XmlSerializationReader) As Object

Parameter

reader
XmlSerializationReader XmlSerializationReader XmlSerializationReader XmlSerializationReader

Der XmlSerializationReader mit dem zu deserialisierenden XML-Dokument.The XmlSerializationReader that contains the XML document to deserialize.

Gibt zurück

Das deserialisierte Objekt.The deserialized object.

Ausnahmen

Wenn die Methode nicht in einer abgeleiteten Klasse überschrieben wird, werden alle Versuche unternommen, auf diese Methode zuzugreifen.Any attempt is made to access the method when the method is not overridden in a descendant class.

Deserialize(XmlReader) Deserialize(XmlReader) Deserialize(XmlReader)

Deserialisiert das im angegebenen XmlReader enthaltene XML-Dokument.Deserializes the XML document contained by the specified XmlReader.

public:
 System::Object ^ Deserialize(System::Xml::XmlReader ^ xmlReader);
public object Deserialize (System.Xml.XmlReader xmlReader);
member this.Deserialize : System.Xml.XmlReader -> obj

Parameter

xmlReader
XmlReader XmlReader XmlReader XmlReader

Der XmlReader mit dem zu deserialisierenden XML-Dokument.The XmlReader that contains the XML document to deserialize.

Gibt zurück

Das Object, das deserialisiert wird.The Object being deserialized.

Ausnahmen

Bei der Deserialisierung ist ein Fehler aufgetreten.An error occurred during deserialization. Die ursprüngliche Ausnahme ist mithilfe der InnerException-Eigenschaft verfügbar.The original exception is available using the InnerException property.

Beispiele

Im folgenden Beispiel wird deserialisiert ein Objekt mit einer XmlReader.The following example deserializes an object using an XmlReader.

#using <System.Xml.dll>
#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Xml;
using namespace System::Xml::Serialization;

// This is the class that will be deserialized.
public ref class OrderedItem
{
public:
    String^ ItemName;
    String^ Description;
    Decimal UnitPrice;
    int Quantity;
    Decimal LineTotal;

    // A custom method used to calculate price per item.
    void Calculate()
    {
        LineTotal = UnitPrice * Quantity;
    }
};

void DeserializeObject( String^ filename )
{
    Console::WriteLine( "Reading with XmlReader" );

    // Create an instance of the XmlSerializer specifying type and namespace.
    XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid );

    // A FileStream is needed to read the XML document.
    FileStream^ fs = gcnew FileStream( filename,FileMode::Open );
    XmlReader^ reader = gcnew XmlTextReader( fs );

    // Declare an object variable of the type to be deserialized.
    OrderedItem^ i;

    // Use the Deserialize method to restore the object's state.
    i = dynamic_cast<OrderedItem^>(serializer->Deserialize( reader ));

    // Write out the properties of the object.
    Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal );
}

int main()
{
    // Read a purchase order.
    DeserializeObject( "simple.xml" );
}
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

// This is the class that will be deserialized.
public class OrderedItem
{
    public string ItemName;
    public string Description;
    public decimal UnitPrice;
    public int Quantity;
    public decimal LineTotal;

    // A custom method used to calculate price per item.
    public void Calculate()
    {
        LineTotal = UnitPrice * Quantity;
    }
}
public class Test
{
    public static void Main(string[] args)
    {
        Test t = new Test();
        // Read a purchase order.
        t.DeserializeObject("simple.xml");
    }

    private void DeserializeObject(string filename)
    {
        Console.WriteLine("Reading with XmlReader");

        // Create an instance of the XmlSerializer specifying type and namespace.
        XmlSerializer serializer = new
        XmlSerializer(typeof(OrderedItem));

        // A FileStream is needed to read the XML document.
        FileStream fs = new FileStream(filename, FileMode.Open);
        XmlReader reader = XmlReader.Create(fs);

        // Declare an object variable of the type to be deserialized.
        OrderedItem i;

        // Use the Deserialize method to restore the object's state.
        i = (OrderedItem)serializer.Deserialize(reader);
        fs.Close();

        // Write out the properties of the object.
        Console.Write(
        i.ItemName + "\t" +
        i.Description + "\t" +
        i.UnitPrice + "\t" +
        i.Quantity + "\t" +
        i.LineTotal);
    }
}
Imports System
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Xml.Serialization
Imports Microsoft.VisualBasic


' This is the class that will be deserialized.
Public Class OrderedItem
    Public ItemName As String
    Public Description As String
    Public UnitPrice As Decimal
    Public Quantity As Integer
    Public LineTotal As Decimal
        
    ' A custom method used to calculate price per item.
    Public Sub Calculate()
        LineTotal = UnitPrice * Quantity
    End Sub
End Class

Public Class Test
    
    Public Shared Sub Main()
        Dim t As New Test()
        ' Read a purchase order.
        t.DeserializeObject("simple.xml")
    End Sub
      
    Private Sub DeserializeObject(ByVal filename As String)
        Console.WriteLine("Reading with XmlReader")
        
        ' Create an instance of the XmlSerializer specifying type and namespace.
        Dim serializer As New XmlSerializer(GetType(OrderedItem))
        
        ' A FileStream is needed to read the XML document.
        Dim fs As New FileStream(filename, FileMode.Open)
        Dim reader As XmlReader = XmlReader.Create(fs)
        
        ' Declare an object variable of the type to be deserialized.
        Dim i As OrderedItem
        
        ' Use the Deserialize method to restore the object's state.
        i = CType(serializer.Deserialize(reader), OrderedItem)
        fs.Close()

        ' Write out the properties of the object.
        Console.Write(i.ItemName & ControlChars.Tab & _
                      i.Description & ControlChars.Tab & _
                      i.UnitPrice & ControlChars.Tab & _
                      i.Quantity & ControlChars.Tab & _
                      i.LineTotal)
    End Sub
End Class

<?xml version="1.0"?>
 <OrderedItem xmlns:inventory="http://www.cpandl.com" xmlns:money="http://www.cohowinery.com">
   <inventory:ItemName>Widget</inventory:ItemName>
   <inventory:Description>Regular Widget</inventory:Description>
   <money:UnitPrice>2.3</money:UnitPrice>
   <inventory:Quantity>10</inventory:Quantity>
   <money:LineTotal>23</money:LineTotal>
 </OrderedItem>

Hinweise

Deserialisierung wird das von einer Instanz von einem XML-Dokument zu lesen und erstellen ein Objekt, das stark auf die XML-Schema (XSD) des Dokuments typisiert ist.Deserialization is the process of reading an instance of an XML document and constructing an object that is strongly typed to the XML Schema (XSD) of the document.

Vor der Deserialisierung ein XmlSerializer muss erstellt werden, mit dem Typ des Objekts, das deserialisiert wird.Before deserializing, an XmlSerializer must be constructed using the type of the object that is being deserialized.

Die XmlReader erkennt automatisch, und der angegebenen Codierung von XML-Dokument.The XmlReader automatically detects and uses the encoding specified by the XML document.

Hinweis

Die XmlSerializer kann nicht deserialisiert werden die folgenden: Arrays von ArrayList und Arrays von List<T>.The XmlSerializer cannot deserialize the following: arrays of ArrayList and arrays of List<T>.

Siehe auch

Deserialize(XmlReader, String) Deserialize(XmlReader, String) Deserialize(XmlReader, String)

Deserialisiert das im angegebenen XmlReader enthaltene XML-Dokument anhand des angegebenen Codierungsstils.Deserializes the XML document contained by the specified XmlReader and encoding style.

public:
 System::Object ^ Deserialize(System::Xml::XmlReader ^ xmlReader, System::String ^ encodingStyle);
public object Deserialize (System.Xml.XmlReader xmlReader, string encodingStyle);
member this.Deserialize : System.Xml.XmlReader * string -> obj

Parameter

xmlReader
XmlReader XmlReader XmlReader XmlReader

Der XmlReader mit dem zu deserialisierenden XML-Dokument.The XmlReader that contains the XML document to deserialize.

encodingStyle
String String String String

Der Codierungsstil des serialisierten XML-Codes.The encoding style of the serialized XML.

Gibt zurück

Das deserialisierte Objekt.The deserialized object.

Ausnahmen

Bei der Deserialisierung ist ein Fehler aufgetreten.An error occurred during deserialization. Die ursprüngliche Ausnahme ist mithilfe der InnerException-Eigenschaft verfügbar.The original exception is available using the InnerException property.

Hinweise

Deserialisierung wird das von einer Instanz von einem XML-Dokument zu lesen und erstellen ein Objekt, das stark auf die XML-Schema (XSD) des Dokuments typisiert ist.Deserialization is the process of reading an instance of an XML document and constructing an object that is strongly typed to the XML Schema (XSD) of the document.

Vor der Deserialisierung ein XmlSerializer muss erstellt werden, mit dem Typ des Objekts, das deserialisiert wird.Before deserializing, an XmlSerializer must be constructed using the type of the object that is being deserialized.

Legen Sie die encodingStyle Parameter, um "http://schemas.xmlsoap.org/soap/encoding/"für SOAP-Version 1.1-Codierung legen Sie sie andernfalls auf"http://www.w3.org/2001/12/soap-encoding" für die Codierung von SOAP-Version 1.2.Set the encodingStyle parameter to "http://schemas.xmlsoap.org/soap/encoding/" for SOAP version 1.1 encoding; otherwise, set it to "http://www.w3.org/2001/12/soap-encoding" for SOAP version 1.2 encoding.

Beachten Sie der XmlSerializer kann nicht deserialisiert werden die folgenden: Arrays von ArrayList und Arrays von List<T>.Note The XmlSerializer cannot deserialize the following: arrays of ArrayList and arrays of List<T>.

Siehe auch

Deserialize(XmlReader, XmlDeserializationEvents) Deserialize(XmlReader, XmlDeserializationEvents) Deserialize(XmlReader, XmlDeserializationEvents)

Deserialisiert ein im XmlReader enthaltenes XML-Dokument und ermöglicht das Überschreiben der Ereignisse, die während der Deserialisierung eintreten.Deserializes an XML document contained by the specified XmlReader and allows the overriding of events that occur during deserialization.

public:
 System::Object ^ Deserialize(System::Xml::XmlReader ^ xmlReader, System::Xml::Serialization::XmlDeserializationEvents events);
public object Deserialize (System.Xml.XmlReader xmlReader, System.Xml.Serialization.XmlDeserializationEvents events);
member this.Deserialize : System.Xml.XmlReader * System.Xml.Serialization.XmlDeserializationEvents -> obj

Parameter

xmlReader
XmlReader XmlReader XmlReader XmlReader

Der XmlReader mit dem zu deserialisierenden Dokument.The XmlReader that contains the document to deserialize.

Gibt zurück

Das Object, das deserialisiert wird.The Object being deserialized.

Hinweise

Das Objekt, das deserialisiert wird.The object being deserialized.

Deserialize(XmlReader, String, XmlDeserializationEvents) Deserialize(XmlReader, String, XmlDeserializationEvents) Deserialize(XmlReader, String, XmlDeserializationEvents)

Deserialisiert das Objekt mit den im angegebenen XmlReader enthaltenen Daten.Deserializes the object using the data contained by the specified XmlReader.

public:
 System::Object ^ Deserialize(System::Xml::XmlReader ^ xmlReader, System::String ^ encodingStyle, System::Xml::Serialization::XmlDeserializationEvents events);
public object Deserialize (System.Xml.XmlReader xmlReader, string encodingStyle, System.Xml.Serialization.XmlDeserializationEvents events);
member this.Deserialize : System.Xml.XmlReader * string * System.Xml.Serialization.XmlDeserializationEvents -> obj

Parameter

xmlReader
XmlReader XmlReader XmlReader XmlReader

Eine Instanz der XmlReader-Klasse zum Lesen des Dokuments.An instance of the XmlReader class used to read the document.

encodingStyle
String String String String

Die verwendete Codierung.The encoding used.

Gibt zurück

Das Objekt, das deserialisiert wird.The object being deserialized.

Hinweise

Diese Methode ist für die Deserialisierung unbekannte Header nur Web-Dienst-Szenarien erforderlich.This method is required for deserialization of unknown headers for Web Service scenarios only. Diese Methode können Sie Ereignis-Synchronisierung in die Webdienst-Methoden zu vermeiden.This method allows you to avoid event synchronization in Web Service methods.

Gilt für: