complete-reference-vb_net_73
complete-reference-vb_net_73
Attributes that are associated with a namespace URI must have a prefix (default namespaces do not apply to
attributes). This conforms to section 5.2 of the "W3C Namespaces in XML" recommendation. If an attribute
references a namespace URI, but does not specify a prefix, the writer generates a prefix for the attribute.
When writing an empty element, an additional space is added between the tag name and the closing tag: for
example, <item />. This provides compatibility with older browsers.
When a String is used as a method parameter, a reference to Nothing and String.Empty is equivalent.
String.Empty follows the W3C rules.
You can also write strongly typed data by using the XmlConvert class which works just like the standard
Convert class. For example, the following line of code converts String data to Double data:
There is a ton of XML specific information that would be terrific to cover but much of it belongs in a book
dedicated to the subject. However, there is one more I/O facility we need to look at in this book before we can
close the long chapter: serialization.
The Soap class is very useful for serializing across and through network boundaries, because the data, XML,
is encapsulated in a SOAP envelope. The framework also provides a namespace specializing in pure XML
serialization streams, essentially serializing into and out of XML documents.
Serialization is very useful for persisting data stored in various data structures. It's also very lightweight and
efficient to use, especially for applications running on Web servers, database servers, and various facilities
that you may need to scale. One scenario where serialization comes in handy is loading data into an
application at start up. The data can be easily piped into an object that is created on the fly at runtime. The
Indexworks application introduced at the beginning of the chapter is one such application.
The outmoded way of loading data into the application at runtime would have you create an array or some
other data structure, initialize the structure, open a flat text file, read the data into the array, and then position
the array for access by the application's various components. The modern approach instead lets you suck in
(serialize) the XML file into the application's processing space, creating and initializing the object that holds
the data all at the same time.
The lattter sophisticated approach cuts out the step of having to read in the data and add it to the elements of
an array or the nodes of a linked list one element or node at a time. It's like having the entire object and all its
data sitting on the disk ready for loading at a moment's notice (in fact it's exactly that).
557