What Deserialization Is
-
Serialization = convert an object → XML (or another format).
-
Deserialization = the reverse: convert XML → object in memory.
-
It allows programs to reconstruct data structures from XML text.
Why It’s Useful
Example (C# style)
XML file:
<Book>
<Title>XML Guide</Title>
<Author>A. Smith</Author>
</Book>
Class:
public class Book {
public string Title { get; set; }
public string Author { get; set; }
}
Deserialization code:
XmlSerializer serializer = new XmlSerializer(typeof(Book));
using (FileStream fs = new FileStream("book.xml", FileMode.Open)) {
Book b = (Book)serializer.Deserialize(fs);
}
Now b.Title = "XML Guide", b.Author = "A. Smith".
Deserialization vs Parsing
-
Parsing: just reading XML structure (like SAX, DOM, StAX).
-
Deserialization: goes further — it maps XML elements directly to object fields/properties.
Advantages
Disadvantages
In short:
Deserialization = taking XML text and rebuilding it into program objects, making XML data usable directly in code.