Chapter 11: Using XML in Visual Basic 2005


Overview

This chapter describes how you can generate and manipulate Extensible Markup Language (XML) using Visual Basic 2005. However, using XML in Visual Basic is a vast area to cover (more than possibly could be covered in a chapter). The .NET Framework exposes five XML-specific namespaces that contain over a hundred different classes. In addition, dozens of other classes support and implement XML-related technologies, such as ADO.NET, SQL Server, and BizTalk. Consequently, this chapter focuses on the general concepts and the most important classes.

Visual Basic relies on the classes exposed in the following XML-related namespaces to transform, manipulate, and stream XML documents:

  • System.Xml provides core support for a variety of XML standards (including DTD, namespace, DOM, XDR, XPath, XSLT, and SOAP).

  • System.Xml.Serialization provides the objects used to transform objects to and from XML documents or streams using serialization.

  • System.Xml.Schema provides a set of objects that enable schemas to be loaded, created, and streamed. This support is achieved using a suite of objects that support the in-memory manipulation of the entities that compose an XML schema.

  • System.Xml.XPath provides a parser and evaluation engine for the XML Path Language (XPath).

  • System.Xml.Xsl provides the objects necessary when working with Extensible Stylesheet Language (XSL) and XSL Transformations (XSLT).

The XML-related technologies utilized by Visual Basic include other technologies that generate XML documents and enable XML documents to be managed as a data source:

  • ADO - The legacy COM objects provided by ADO have the ability to generate XML documents in stream or file form. ADO can also retrieve a previously persisted XML document and manipulate it. (Although ADO is not used in this chapter, ADO and other legacy COM APIs can be accessed seamlessly from Visual Basic.)

  • ADO.NET - This uses XML as its underlying data representation: The in-memory data representation of the ADO.NET DataSet object is XML; the results of data queries are represented as XML documents; XML can be imported into a DataSet and exported from a DataSet. (ADO.NET is covered in Chapter 10.)

  • SQL Server 2000 - XML-specific features were added to SQL Server 2000 (FOR XML queries to retrieve XML documents and OPENXML to represent an XML document as a rowset). Visual Basic can use ADO.NET to access SQL Server’s XML-specific features (the documents generated and consumed by SQL Server can then be manipulated programmatically). Recently, Microsoft also released SQLXML, which provides an SQL Server 2000 database with some excellent XML capabilities, such as querying a database using XQuery, getting back XML result sets from a database, working with data just as if it were XML, taking huge XML files and having SQLXML convert them to relational data, and much more. SQLXML enables you to perform these functions and more via a set of managed .NET classes. You can download SQLXML free from the Microsoft SQLXML website at http://msdn.microsoft.com/sqlxml.

  • SQL Server 2005 - SQL Server has now been modified with XML in mind. SQL Server 2005 can natively understand XML because it is now built into the underlying foundation of the database. The ability to query and understand XML documents is a valuable addition to this database server. SQL Server 2005 also comes in a lightweight (and free) version called SQL Server Express Edition.

This chapter makes sense of this range of technologies by introducing some basic XML concepts and demonstrating how Visual Basic, in conjunction with the .NET Framework, can make use of XML. Specifically, you will

  • Learn the rationale behind XML.

  • Look at the namespaces within the .NET Framework class library that deal with XML and XML-related technologies.

  • Take a closer look at some of the classes contained within these namespaces.

  • Gain an overview of some of the other Microsoft technologies that utilize XML, particularly SQL Server and ADO.NET.

At the end of this chapter, you will be able to generate, manipulate, and transform XML using Visual Basic.




Professional VB 2005 with. NET 3. 0
Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
ISBN: 0470124709
EAN: 2147483647
Year: 2004
Pages: 267

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net