The sqldatasource and objectdatasource controls are both flat table-based data source controls, and the operations are relatively simple. I will not elaborate on them here.
In ASP. NET, how does one process XML data? The following is a detailed explanation.
Here I will talk about the xmldatasource used to connect the XML file and the sitemapdatasource used to connect the site navigation data. The xmldatasource data in these two levels is bound to the flat table control.
The xmldatasource control allows other controls to be bound to XML data. Xmldatasource supports the datafile attribute, which is used to specify the path of the XML data file as input. You can also specify the tranformfile attribute to apply XSLT to the data, and set the XPath attribute to specify a subset of the data source nodes to be exposed.
Transformfile = "~ Transxml "XPath =" // user ">
It is also feasible to bind a table-type data binding control to a layered data source, but it can only display the first layer of data. In the demo below, the repeater control is bound to the temp. xml file. Because the top-level nodes exposed by the data source are nodes, the repeater can use the eval Data Binding syntax in its own itemtemplate template to bind the attributes of these nodes.
Title name: Email:
In addition to the eval Data Binding syntax, ASP. NET 2.0 also provides the XPath-based Data Binding syntax, which can be used for any data item that implements the ixpathnavigable interface. Here we will introduce two common expression types:
◆ XPath (expression, [formatstring])-calculate the value of the XPath expression based on the data item and return a single value.
◆ Xpathselect (expression, [formatstring])-calculate the XPath expression value based on the data item and return the node list.
Next, let's take a look at the advantages of using the XPath data binding method. We can use a demo to describe it.
A repeater is added to the itemtemplate of repeater, and the internal repeater attribute is bound to an xpathselect expression describing the reply subnode of the current user node. In the itemtemplate template of the internal repeater, The XPath data binding expression calculates the value based on these "reply" content nodes. ASP. NET 2.0 uses this technology to easily construct a rich and hierarchical data display mode by using the combined table format data binding control.