Asp + uses data binding to process XML files

Source: Internet
Author: User

/*
Tofu is made of excellent products
Http://www.asp888.net bean curd technology station
Retain the copyright information if reprinted.
*/
Test. aspx is the main running program site. xml is an xml file containing data

<% @ Import Namespace = "System. IO" %>
<% @ Import Namespace = "System. Data" %>

<Html>
<Script language = "VB" runat = "server">
Sub Page_Load (Src As Object, E As EventArgs)
Http://www.asp888.net
Dim DS As New DataSet
Dim FS As FileStream
Dim Reader As StreamReader

FS = New FileStream (Server. MapPath ("site. xml"), FileMode. Open, FileAccess. Read)
Reader = New StreamReader (FS)
DS. ReadXml (Reader)
FS. Close ()
Dim Source As DataView
Source = new DataView (ds. Tables (0 ))
MyDataGrid. DataSource = Source
MyDataGrid. DataBind ()
End Sub
</Script>

<Body>

<H3> <font face = "Verdana"> technical site overview </font> <span runat = "server" id = "MySpan"/>

<ASP: DataGrid id = "MyDataGrid" runat = "server"
Width = "800"
BorderColor = "black"
ShowFooter = "false"
CellPadding = 3
CellSpacing = "0"
Font-Name = "Verdana"
Font-Size = "8pt"
HeaderStyle-BackColor = "# aaaadd"
>
<Property name = "Columns">
<Asp: HyperLinkColumn
DataNavigateUrlField = "url"
DataNavigateUrlFormatString = {0}
Text = "visit! "
/>
</Property>
</ASP: DataGrid>


</Body>
</Html>

Content of the site. xml file

<Root>
<Schema id = "allsite" targetNamespace = "" xmlns = "http://www.w3.org/1999/XMLSchema" xmlns: xdo = "urn: schemas-microsoft-com: xml-xdo" xdo: dataSetName = "books">
<Element name = "sites">
<ComplexType content = "elementOnly">
<Element name = "url" type = "string" minOccurs = "1" allownull = ""> </element>
<Element name = "site" type = "string" minOccurs = "1"> </element>
<Element name = "content" type = "string" minOccurs = "0" maxoccurs = "1"> </element>
</ComplexType>
</Element>
</Schema>

<Allsite>
<Sites>
<Url> http://www.asp888.net </url>
<Site> tofu </site>
<Content> tofu is made in excellent products </content>
</Sites>
</Allsite>

</Root>

Author: Tofu


Related Article

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.