asp.net processing XML Data Example--practical skills

Source: Internet
Author: User

This article describes the asp.net processing of XML data, sharing for everyone's reference. The implementation methods are as follows:

XML is an Extensible Markup language, which is much more flexible than the HTML mentioned earlier, although it is only a poor one with HTML, but there is a big difference between the two.

XML is also a markup language, so it must be closed for each label, and HTML occasionally forgetting to close does not have much effect (it is not recommended that you can omit, good writing specifications or have)

Secondly, XML as a kind of pure text, its main role is not to be directly displayed on the Web page, but as a data storage or transmission tool. When it comes to the level of data, XML is important, and some data can be used without the sql,oracel of large databases, and XML is necessary.

The following example involves ASP.net reading and displaying XML, and you can look at it.

Full instance code click here to download the site.

There is nothing to say about the syntax and specification of XML, and here is an example of ASP.net manipulating xml:

Special attention? There can be no space between the XML, otherwise the operation will be wrong!

Copy Code code as follows:
<?xml version= "1.0" encoding= "GB2312"?>//Save As Course.xml
<courses>
<course>
<id>1</id>
<title> Tom Cruise </title>
<url>mission impossible.mp3</url>
</course>
<course>
<id>2</id>
<title> DiCaprio </title>
<url>my Heart'll go on.mp3</url>
</course>
</courses>

The dataset provides methods for processing XML documents: ReadXml reading documents, WriteXml writing to documents, and so on.

Objective: To read the contents of an XML document in a dataset and display it in the GridView. (Note import System.Data, System.Data.OleDb namespaces)

Copy Code code as follows:
protected void Page_Load (Object Sender,eventargs e)
{
DataSet DS = new DataSet (); Creating a DataSet Object
Ds.  ReadXML (Server.MapPath ("Course.xml")); Reading XML documents
Gridview1.datasource = DS. Tables[0]. DefaultView;
Gridview1.databind ();
}

I hope this article will help you with the ASP.net program design.

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.