Web ASP: XML controls

Source: Internet
Author: User

Default. aspx

View code

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 

Background code

View code

   protected void Page_Load(object sender, EventArgs e)    {        XmlDocument doc = new XmlDocument();        doc.Load(Server.MapPath("test.xml"));        XslTransform trans = new XslTransform();        trans.Load(Server.MapPath("test.xsl"));        Xml1.Document = doc;        Xml1.Transform = trans;    }

Test. xml

View code

<? XML version = "1.0" encoding = "UTF-8"?> <Publication> <book> <title> C # Full database system development manual </title> <pages> 628 </pages> </book> <title> Asp. net Program Development example book </title> <pages> 820 </pages> </book> </publication>

Test. XSL

View code

<? XML version = "1.0" encoding = "UTF-8"?> <XSL: stylesheet version = "1.0" xmlns: XSL = "http://www.w3.org/1999/XSL/Transform"> <XSL: template match = "/"> <HTML> <body> <! -- This Is An XSLT template file. fill in this area with the XSL elements which will transform your XML to XHTML. --> <Table width = "300" Height = "30" border = "10" cellspacing = "0" cellpadding = "0"> <tr align = "center"> <TD> title </TD> <TD> page number </TD> </tr> <XSL: for-each select = "publication/book"> <tr align = "center" Height = "30"> <TD> <XSL: value-of select = "title"/> </TD> <XSL: value-of select = "pages"/> </TD> </tr> </XSL: for-each> </table> </body> 

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.