CS 112D Lecture Notes - XML Basics - Chapters 9 and 10
XML
XML Family of Technologies (Chapter 9)
- XPATH - XML Path Language - provides a way to query information from an XML document
- XSLT - Extensible StyleSheet Language Transformations - provides a langauge for modifying the
data in one XML document to be used in another XML document.
- XSL - Extensible StyleSheet Langauge - basically XSLT plus ability to specify how information
is to be displayed within browser or other application.
- DOM - Document Object Model - contains functions to allow programs to extract data from XML
documents.
- System.XML - namespace in which the following classes are defined
- XMLDocument - a class in VS.NET to work with an XML document. Its "Load" method loads a
document into memory.
- XmlNode - an object to store the information from an XML node.
- XmlNodeList - an object to store a list of nodes.
- Here is the XMLDomSample project from the textbook
- SOAP - Simple Object Access Protocol - specification for communication between applications
across the web.
- SQLXML - An extension of SQL Server which allows us to query a database and produce results in
XML format. It requires IIS (Internet Information Server) and full-fledged SQL Server to be installed, so
we won't be able to use it in this class, but at the end of Chapter 9, your book shows how to use it to
produce a report in HTML format.
Reading and Writing XML with ADO.NET (Chapter 10)
- XML documents can be loaded into DataSets, and output from them.
- ReadXml - method of DataSet to read data from an XML document. Its argument can be the name
of an XML file, an XmlReader object, etc. A second argument can specify one of the XmlReadMode
enumeration values below:
- ReadSchema - indicates that schema info should be read in addition to data.
- IgnoreSchema - indicates that schema info should be ignored.
- InferSchema - indicates that inline schema info should ignored, but schema info should be
inferred from structure of data.
- Fragment - Read XML fragments and loads data matching DataSet's schema, ignoring non-
matching data.
- DiffGram - Reads a DiffGram containing multiple row states for some records - when primary
keys match, new rows are merged with existing rows.
- Auto - default mode - DiffGram used if XML fits that format, ReadSchema used if schema
defined, InferSchema otherwise.
- ReadXml sets RowState of all loaded records to Added, because the assumption is that you'll
want to add them to a database. Of course, you can call AcceptChanges to mark them Unchanged.
- ReadXmlSchema - method of DataSet to read just schema info from XML.
- WriteXML - method of DataSet to write data and/or schema to XML file.
- If DataSet contains multiple DataTables, and no relationship exists between them, then the tables are
written to the file one after the other.
- If two or more DataTables have defined relationships, their records will be nested.
- A second argument to WriteXML can specify one of the XmlWriteMode enumeration values below:
- DiffGram - Writes DataSet contents as a DiffGram, with both original and current vales for
all rows
- WriteSchema - Includes an inline schema.
- IgnoreSchema - default - Writes data only.
- WriteXmlSchema - saves just the XML schema as an independed XSD file.
- DiffGram - an XML format allowing for pre- and post- change values for each record.
- ExecuteXmlReader - method of Command object to retrieve data from select query and return an
XmlReader object.
- XmlReader - a class that is similar to a DataReader, containing XmlNodes for each record
- ADO-XML project from book. This project uses the pubs database, which can
be setup from the instpubs.sql script file which is in your MSDE/SQL Server installation directory.
Return to the main CS 112D page