1. Write dataset to a file and write dataset to a file.
• Dataset. writexml ()
• Xmlwritemode
-Writeschema: writes the current content of the dataset in XML format, and uses the relational structure as the inline XSD architecture.
If dataset only has a schema but no data, only the inline schema is written. If dataset does not have the current schema, nothing is written.
-Ignoreschema: writes the current content of the dataset in XML format without architecture. If no data is loaded into dataset, NO content is written.
-DiffGram: writes the entire dataset as a DiffGram, including the original value and current value. To generate a DiffGram that only contains the modified value, call getchanges,
Then, writexml is called as DiffGram on the returned dataset.
2. read data from the XML file to Dataset
• Dataset. readxml ()
• Xmlreadmode
-Auto: default value.
-Readschema: read any inline schema and load data. If the dataset already contains the schema, you can add the new table to the schema.
If any table already exists in dataset, an exception is thrown.
-Ignoreschema: ignores any inline architecture and reads data into the existing dataset. If any data does not match the existing architecture, the data will be discarded.
(Including data in different namespaces defined for dataset ). If the data is DiffGram, ignoreschema has the same function as DiffGram.
-DiffGram: Read DiffGram and apply the changes in DiffGram to dataset. The semantics is the same as that of merge operations. As with merge operations, retained
The rowstate value can only use the rowstate value in writexml to input to the DiffGram of readxml. The DiffGram input to readxml can only use
DiffGram output.
-Inferschema: ignore any inline schema, deduce the schema from the data and load the data. If the dataset already contains the schema, add a new table or add columns to the existing table,
To expand the current architecture. If the inferred table already exists but has different namespaces, or if the inferred column conflicts with the existing column, an exception is thrown.
-Fragment: reads XML fragments from sqlserver instances (for example, XML fragments generated by running forxml queries ). When xmlreadmode is set
In fragment, the namespace is read as the inline schema by default.
-Infertypedschema: ignore any inline schema, deduce a strong schema from the data, and load the data. If the data cannot be inferred from the data, it is interpreted as string data.
If the dataset already contains the schema, you can add a new table or add columns to the existing table to expand the current schema. If the inferred table already exists
However, it has a different namespace or if some of the columns to be inferred have a different namespace than the existing columns,
Or if the inferred columns conflict with existing columns, an exception is thrown.
3. Get XML results
• Dataset. getxml ()
• Call this method is the same as call writexml and set xmlwritemode to ignoreschema.
• Getxml returns XML as a string. Therefore, it requires more system overhead than writexml, which writes XML to a file.
• If schema inference is used to generate a dataset and serialize it using XML or web services, the column sorting method may change.
4. For XML statements in SQL Server
• Extended select syntax
• The returned XML replaces the XML returned by rows and columns, and replaces the rows and columns.
• Can be configured to return attributes, elements, and Architectures
• Benefits from using XML Client Applications
5. Raw mode Query
6. query in Auto Mode
• XML Representation of data entities
• XML Representation of data entities
• Nested Data Based on connection priority
• Options such as elements and root can be used
7. query in explicit Mode
8. query in path Mode
• Use XPath to specify the XML format
• Allows creation of nested data
• Easier than using the explicit it Mode
9. display the syntax of Nested XML
10. Detailed description of the. NET XPath Processing Engine
• Dom
-Heavyweight read/write
-Random Access
-Easy access to complex object models
• Xmlreader
-Lightweight Access
-Read-Only
-Forward only
-Fast Access
A. Create an xpathnavigator object
• The following classes all implement the ixpathnavigable interface of the system. xml. XPath namespace. You can use the createnavigator method to return the xpathnavigator object.
-Xpathdocument
-Xmldocument
-Xmlnode
• The xpathnavigator object allows you to select, compute, browse, and (in some cases) EDIT basic XML data.
• Select a node
-Select ()
-Selectsinglenode ()
• Calculate the XPath expression
-Evaluate ()
• Match nodes and XPath expressions
-Matches ()
B. Access XML data
• Outerxml attributes
-This interface is used to obtain the markup of the entire XML document or only the markup of a single node and Its subnodes.
• Readsubtree () method
-It is used to process all the content of an XML document or streams from a single node and Its subnodes to the xmlreader object.
C. Edit XML data
• Insert nodes
-Insertafter, insertbefore, insertelementafter, insertelementbefore
-Appendchild, prependchild, appendchildelement, and prependchildelement
-Createattribute and createattributes
• Modify a node
-Setvalue and settypedvalue
• Delete a node
-Deleteself