Using Visual Basic 9.0 FOR XML programming

Source: Internet
Author: User
Tags object model visual studio

So far, you've probably heard of LINQ (Language Integration Query), which is the new query technology that comes with visual studio®2008. LINQ-enabled languages, such as visual basic®, provide you with a rich set of query operators that you can apply to a variety of data sources, such as in-memory collections, databases, datasets, and XML. This technology is already very good, but visual Basic 9.0 actually provides much more than that, making XML a first-class data type that is directly integrated into the language.

Now you may want to know why you need to integrate XML data types directly into Visual Basic. Today, many applications are using XML for storage and data transfer. XML is widely used in the industry because of its flexibility and simplicity, and it is also used for many applications that perform storage and data transfer functions. Because XML is self-describing (that is, the structure of the data is included in the data), it is particularly suitable for transferring data between systems. Furthermore, it is much easier to read data that is constructed inside an XML tag than to write analysis rules for various custom file formats.

The problem with XML, however, is that developers have never been very easy to use it. Confusing and inconsistent APIs, such as the Document Object Model (DOM), and languages such as XSLT and XQuery, are often difficult to read and understand. But after the introduction of LINQ and Visual Basic 9.0, XML development has become much easier. In this column, you will explore the current XML programming experience, how LINQ improves the experience, and how Visual basic provides more support when working with XML.

Using the DOM

First, suppose you need to write out a list of customers in XML. My customer list has the following properties: FirstName, LastName, address, city, state, and ZipCode. When you convert a list to XML, it should look like Figure 1.

Customer List Properties in Figure1xml

<Customers>
<Customer FirstName="Jane" LastName="Dow">
<Address>123 Main St</Address>
<City>Redmond</City>
<State>WA</State>
<ZipCode>10104</ZipCode>
</Customer>
<Customer FirstName="Matt" LastName="Berg">
<Address>456 First St</Address>
<City>Seattle</City>
<State>WA</State>
<ZipCode>10028</ZipCode>
</Customer>
</Customers>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.