Applied XML programming for Microsoft .NET

Author : Dino Esposito
Microsoft Press
ISBN-0-7356-1801-1
This book covers the way .NET works with data, from the settings in a
configuration file to database data. XML is the native data format of the .NET
framework and it is a data format also understood by the outside world making it
a de-facto standard for (platform) interoperability.
This book is no theoretical tutor on XML, if that interests you, you're
better off reading XML for ASP.NET developers. It
focuses on using XML. The book is dived in four parts.
- XML core classes in the .NET framework
The first thing you'll probably associate XML with is a textual
representation of data caught between <tags>. The first part of this book looks
how the .NET classes parse this text to data in real .NET objects. The different
approaches between an XML document versus XMLreaders and XMLwriters are treated.
An XML document is an in memory structure which can be manipulated at will. XML
readers and writers operate on a stream of data. This stream can be as diverse
as a disk file or a network stream. A piece of XML can describe itself in a
schema, a whole chapter is spent on validating data against a schema.
The easiest and most flexible way to manipulate XML data is loading it in an
XML document, which is based on the XML Document Object Model (DOM)
specification. These documents are structured in a tree form, which expresses
the relationship between the data elements. In a detailed treatment you will
learn how to manipulate these documents. XPath, the XML query language, helps
you find your way and data in an XML document using expressions. In the .NET
framework you can use XPath to navigate through an XML document. An alternative
is to use the XpathDocument class, which wraps up a chuck of XML data and the
way to access the data inside is then using Xpath queries. The part concludes
with a chapter on XSLT, an almost classical way to transform XML data into an
other document like an HTML page or a Comma Separated Values file. The
transformation is described in an XSLT document, an extra the .NET framework has
to offer is using .NET objects in the XSLT document.
The classical way to store data is in a database, where the application
program reads and writes data to the database using SQL queries. Most recent
databases support XML extensions to SQL, they can return data in an XML format
and do accept updates in an XML format. The .NET framework supports some classes
which fold XML database access into the standard way .NET works with databases.
The core class which holds data in a .NET application is the ADO.NET dataset. As
the only class in the framework it natively supports serialization. Datasets are
binary objects like any other object. But the dataset class has methods which
produce the data contents in the form of XML. This XML is one stream of text and
can be sent in a file or stream to a recipient. The dataset has also methods for
reading an XML text-stream to populate the data. A .NET application always works
with disconnected data, data is read from the database into the dataset after
which the application can work with it. To record all changes the dataset uses
the diffgram format, Dino spends a whole chapter on the workings of the format
and how the updates in the dataset are brought back to the database.
- Applications interoperability
A component of a .NET application communicates with another component by
exchanging serialized streams of data. These streams can have different formats.
The ADO.NET datasets produces streams in XML-format. If you want to send objects
of another class to another component you have to do your own serialization. The
.NET framework provides formatters to help you, the binary formatter generates a
binary stream, the SOAP formatter generates a stream which can be used in web
services. In a chapter on XML serialization Dino explains how to use the
formatters to serialize objects of your own classes. When the .NET component
you're using is running on another machine you have a remoting scenario. .NET
remoting solves the issues DCOM used to do but does come with the associated
configuration and deployment nightmare. In one chapter is described what it does
take to make a .NET class remotable and how objects of that class can be used on
a remote client. In a .NET remoting scenario all parties are .NET components, to
exchange functionality with a non .NET client or server, or even a non Windows
piece of software, you enter the world of web services. In a dedicated chapter
Dino describes the .NET support for web services in servers and clients.
The two concluding chapters don't really fit in the inter-operability part.
In a chapter on XML on the client the XML support in Internet explorer (which
will be the program the user of most .NET applications is running) is discussed.
The last chapter describes how to configure a .NET application using XML
configuration files. Besides the general configuration of an application you can
use these files to store your own app-settings, making (write) access to the
Windows registry no longer necessary.
Conclusion
I would recommend this book to everybody who is creating .NET applications.
It's title might suggest a smaller coverage of .NET than the actual content.
After reading it you will see how XML is the way to treat data in .NET (and the
world outside .NET) and how it is utilized in every corner of the framework. As
a companion I would suggest Dan Wahlin's book on XML to
understand the background and as a reference on XML. The style of Dino
Esposito's book is nice and easy and the examples are very clear. It is almost
as much fun to read this book than that it is to program in .NET.
|