C # Web XML programming (from ourasp)

Source: Internet
Author: User
C # Web XML Programming
Tang Yijun | 2002-1-25
--------------------------------------------------------------------------------

Due to XML's ease of sharing and many other advantages, XML technology is increasingly used in enterprise data processing and other fields, such as Enterprise reports, news releases, and accounting data processing.
XML is quickly becoming a tool for transferring data from the middle layer to the desktop. Because XML data can be integrated with multiple backend (database) sources through the middle layer proxy, most database manufacturers currently fully support XML technology, provides various powerful functions to process XML data.
Microsoft's. NET provides a powerful and fast development tool-C #, which features unprecedented development efficiency, especially in XML programming.
C # provides many related classes to process XML data, such as stream processing classes: XmlReader and XmlWriter; DOM classes: XmlNode, XmlDocument, and XmlElement; Xpath classes: XmlNavigator; XSLT class: XslTransform.
Show XML file content
C # programming is used to display information in XML files. the standard class provided by NET reads XML file content into a StreamReader class object, and then reads XML Information to DataSet using the XmlDataDocument class DataSet to read XML information, dataSet is assigned to a DataGrid on the Web Form in the Form of DataView, and DataBind displays the data. The specific implementation code is as follows:
Using System. Xml;
// The Namespace required for processing XML. You must also add System. XML. Dll in References.
Using System. IO;
// Namespace required for reading XML files
Then add the following code to Page_Load:
Protected void Page_Load (object sender, EventArgs e ){
String datafile = "guest. xml ";
// Assume that the XML file name is guest. xml.
StreamReader tyj = new StreamReader (Server. MapPath (datafile ));
XmlDataDocument datadoc = new XmlDataDocument ();
// Create this object to read XML
Datadoc. DataSet. ReadXml (tyj );
// Read the content of the guest. xml file
DataGrid1.DataSource = datadoc. DataSet. Tables [0]. DefaultView;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.