Chapter 8

Using XML with Visual Basic

What's in this chapter?

The rationale behind XML

How to serialize objects to XML (and vice versa)

How to read and write XML

How to use LINQ to XML to read and edit XML

How to use XML literals within your code

Wrox.com Code Downloads for this Chapter

The wrox.com code download for this chapter is found at www.wrox.com/remtitle.cgi?=isbn=9781118314456 on the Download Code tab. The code is in the chapter 8 download. The code for this chapter is a single solution with multiple projects. Each project represents a separate example.

This chapter describes how you can generate and manipulate Extensible Markup Language (XML) using Visual Basic 2012. The .NET Framework exposes many XML-specific namespaces that contain over 100 different classes. In addition, dozens of other classes support and implement XML-related technologies, such as those provided in ADO.NET, SQL Server, and BizTalk. Consequently, this chapter focuses on the general concepts and the most important classes.

The chapter is organized from older technologies and lower-level XML manipulation to the latest and greatest functionality. This is done because it is important you understand how XML is actually structured and manipulated in order for you to gain the most from it.

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 (Document Type Definition), namespace, DOM (Document Object Model), XDR (XML Data Reduced — an old version of the XML schema standard), XPath, XSLT (XML Transformation), and SOAP (formerly Simple Object Access Protocol; now the acronym doesn't stand for anything).
  • 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 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).
  • System.Xml.Linq provides the support for querying XML using LINQ (also covered in chapter 9).

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.

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset