Summary

In this chapter, you learned about SQL Server's extensive support for XML. You also saw how to store XML in a C# program using the XmlDocument and XmlDataDocument objects.

SQL Server extends the SELECT statement to allow you to query the database and get results back as XML. Specifically, you can add a FOR XML clause to the end of a SELECT statement, which specifies that SQL Server is to return results as XML.

You examined the Extensible Markup Language Path (XPath) and the Extensible Stylesheet Language Transformation (XSLT). XPath is a language that allows you to search and navigate an XML document using expressions. XML is a great way to represent data in a portable format, but XML doesn't contain information on how to format that data for display. XSLT allows you to control the formatting of XML data, and may be used to transform XML data to a format suitable for display.

You can access SQL Server using HTTP (Hypertext Transfer Protocol). This allows you to run SQL statements from a browser; for example, you can run a SELECT statement that returns XML, and SQL Server will display the results in you browser. You can use XPath statements to locate data in the returned XML, and use XSLT stylesheets to format the returned XML.

SQL Server contains a function named OPENXML() that allows you to read XML data as if it were a result set of rows. One use of OPENXML() is to read XML data as rows and then insert those rows into a table.

You use an object of the XmlDocument class to represent an XML document in a C# program. An XmlDocument object stores the nodes of the XML document in objects of the XmlNode class. You can, for example, load rows from the database into a DataSet, and then load an XML representation of those rows into an XmlDocument object.

You use an object of the XmlDataDocument class to access rows as both XmlNode objects and relational DataRow objects. You associate a DataSet with your XmlDataDocument by passing your DataSet to the XmlDataDocument constructor. An XmlDataDocument object provides synchronization between the DataSet and the XML document. For example, if you add a new customer as an XmlNode object to your XmlDataDocument, then that customer is also added as a DataRow to your associated DataSet.

In the next chapter, you'll learn about Web services.




Mastering C# Database Programming
Mastering the SAP Business Information Warehouse: Leveraging the Business Intelligence Capabilities of SAP NetWeaver
ISBN: 0764596373
EAN: 2147483647
Year: 2003
Pages: 181

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