ASP.NET and XML connection

xiaoxiao2021-03-06  107

The development site is a bit numb, and many data is found in use, but only one or two months will be updated for a while. This must be placed in the database and increase the burden on the database. So I want to put this data into XML, but I found that there is no database from the database when making modifications and output! I don't know if everyone doesn't feel like this?

Ok, the words are forwarded in use, I wrote a class is used with the DataSource interface! The code is as follows: use system; use system.xml; using system.data;

Namespace XML {///

/// XML's summary description. /// public class txml {/// /// Create an XML write task /// public txml () {// // TODO: Add constructor logic / /} /// /// Custom data binding /// /// XML file path /// XPath query /// returns the pretext DataSource corresponding public ICollection CreateDataSource (string XmlFilePath, string XmlPath) {DataTable dt = new DataTable (); DataRow dr; XmlDocument XD = new xmldocument (); xd.load (xmlfilepath); XMLNodelist XL = xd.selectnodes (xmlpath); if (xl! = null && xl.count> 0) {INT J; for (j = 0; J

For (int i = 0; i

} DataView DV = New DataView (DT); Return DV;}}}

In this class, I use the XMLDocument XPath to query the data.

If I want a record under a node, I only need to type DataGrid1.datasource = new TXML (). CreateDataSource (Server.MAppath ("A.XML"), "// Data / D"); DataGrid1.Database (); You can also implement paging

The younger brother is too much to ask for a lot of points.

转载请注明原文地址:https://www.9cbs.com/read-125501.html

New Post(0)