This chapter covers the following Microsoft-specified objective for the "Consuming and Manipulating Data" section of the "Developing XML Web Services and Server Components with Microsoft Visual Basic .NET and the Microsoft .NET Framework" exam:
Access and Manipulate XML Data.
Access an XML file by using the Document Object Model ( DOM ) and an XmlReader.
Transform DataSet data into XML data.
Use XPath to query XML data.
Generate and use an XSD schema.
Write a SQL statement that retrieves XML data from a SQL Server database.
Update a SQL Server database by using XML .
Validate an XML document.
Extensible Markup Language (far better known as XML) is pervasive in .NET. It's used as the format for configuration files, as the transmission format for SOAP messages, and in many other places. It's also rapidly becoming the most widespread common language for many development platforms.
This objective tests your ability to perform many XML development tasks . To pass this section of the exam, you need to know how to read an XML file from disk and how to create your own XML from a DataSet in your application. You'll also need to be familiar with the XPath query language and with the creation and use of XSD schema files.
You'll also need to understand the connections that Microsoft SQL Server has with the XML universe. You need to be able to extract SQL Server data in XML format and to be able to update a SQL Server database by sending it properly-formatted XML.
Finally, the exam tests your ability to validate XML to confirm that it conforms to a proper format. The .NET Framework includes several means of validating XML that you should be familiar with.
Accessing an XML File
Understanding the DOM
Using an XmlReader Object
The XMLNode Class
The XmlDocument Class
Synchronizing DataSets with XML
The XmlDataDocument Class
Synchronizing a DataSet with an XmlDataDocument
Starting with an XmlDataDocument
Starting with a Full DataSet
Starting with an XML Schema
The XPath Language
Using the XPathNavigator Class
Selecting Nodes with XPath
Navigating Nodes with XPath
Generating and Using XSD Schemas
Generating an XSD Schema
Using an XSD Schema
Validating Against XSD
Validating Against a DTD
Using XML with SQL Server
Generating XML with SQL Statements
Understanding the FOR XML Clause
Updating SQL Server Data by Using XML
Apply Your Knowledge
S TUDY S TRATEGIES
Use the XmlDocument and XmlNode objects to navigate through some XML files. Inspect the node types that you find and understand how they relate to the original XML.
Use the XmlDataDocument class to synchronize a DataSet with an XML file. Save the XML file to disk and inspect its contents. Understand how the generated XML relates to the original DataSet.
Use an XPath processor to run XPath queries against an XML file. Make sure you know the XPath syntax to select portions of the XML.
Use the methods of the DataSet or XmlDocument objects to create XSD files. Inspect the generated XSD and understand how it relates to the original objects.
Use XML to read and write SQL Server data. You can install the MSDE version of SQL Server from your Visual Studio .NET CD-ROMs if you don't have a full SQL Server to work with.
Use the XmlValidatingReader to validate an XML file. Make a change to the file that makes it invalid, and examine the results when you try to validate the file.
Review the XML Data section of the Common Tasks QuickStart Tutorials that ships as part of the .NET Framework SDK.