Controls involving XML

Source: Internet
Author: User
Tags xslt
Contents
 
1. asp: xmldatasource
 
2. asp: XML
 
3. asp: sitemapdatasource
 
4,Client XML Control
 
5. other server controls

I. xmldatasource: function: enables XML data to be used for data binding controls. Display Hierarchical XML data; attributes: datafile, transformfile, and XPath;
 
<Asp: xmldatasource id = "mysource" datafile = "~ /App_data/bookstore. xml "XPath =" Bookstore/genre [@ name = 'fiction ']/book "runat =" server "> </ASP: xmldatasource>
1. Use the datafile attribute to specify the XML file to load XML data. 2. The control exposes the attributes of the XML element to fields that can be bound to Data. 3. Use XPath to filter data. You can also use the data attribute to embed XML data:
<Asp: Treeview id = "treeview1" runat = "server" performanceid = "xmlperformance1"> <databindings> <asp: treenodebinding imageurl = "~ /Images/openbook.gif "textfield =" title "datamember =" book "/> <asp: treenodebinding imageurl = "~ /Images/notepad.gif "textfield =" name "datamember =" chapter "/> </databindings> </ASP: Treeview> </div> <asp: xmldatasource id = "xmlperformance1" runat = "server" XPath = "Bookstore/book"> <DATA> <bookstore> <book ISBN = "10-861003-324" Title =" tale of Two Cities "Price =" 19.99 "> <chapter num =" 1 "name =" Introduction "> abstract... </Chapter> <chapter num = "2" name = "body"> abstract... </Chapter> <chapter num = "3" name = "conclusion"> abstract... </Chapter> </book> <book ISBN = "1-861001-57-5" Title = "Pride and Prejudice" Price = "24.95"> <chapter num = "1 "Name =" Introduction "> abstract... </Chapter> <chapter num = "2" name = "body"> abstract... </Chapter> <chapter num = "3" name = "conclusion"> abstract... </Chapter> </book> </bookstore> </data> </ASP: xmldatasource>

Ii. asp: XML: used to display XML documents or XSL conversion results,

attribute description . Net
document I do not agree to use it. Specifies the XML document that uses the system. xml. xmldocument object. 1.0
documentcontent specify an XML string. 1.0
documentsource specifies the path of the XML document displayed in the XML control. 1.0
runat specifies that the control is a server control. Must be set to "server ". 1.0
transform use the system. xml. XSL. Transform transform object to format the XML document. 1.0
transformargumentlist contains the list of optional parameters that are passed to the style sheet and used in the extended style sheet language conversion (XSLT.
transformsource specifies the path of the XSL conversion file.
xpathnavigator the cursor model used to navigate and edit XML data associated with the XML control.

by setting the transformsource attribute, you can specify an XSL conversion (XSLT) style table, which is formatted before the XML document is written to the output stream. These two attributes indicate different types of XSL conversion styles that can be used to format XML documents: Implementation subscription instance: Client:

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "progxmlserverltransform. aspx. cs" inherits = "progxmlserverltransform" %> <! 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">  

Server:

 

Using system; using system. collections. generic; using system. LINQ; using system. web; using system. web. ui; using system. web. UI. webcontrols; using system. XML; using system. XML. XSL; public partial class progxmlserverltransform: system. web. UI. page {protected void page_load (Object sender, eventargs e) {} protected void btn_click (Object sender, eventargs e) {xmldocument Doc = new xmldocument (); Doc. load ("HTTP : // Www.cnblogs.com/rss "); xml1.document = Doc; xml1.transformsource = "~ /App_data/RSS. XSL ";}}

RSS. XSL:

 

 

<? XML version = "1.0" encoding = "UTF-8"?> <XSL: stylesheet version = "1.0" xmlns: XSL = "http://www.w3.org/1999/XSL/Transform"> <XSL: template match = "/"> <XSL: apply-templates select = "RSS/channel"/> </XSL: Template> <XSL: template match = "channel"> <H2> <a href = "{link}" target = "_ blank"> <XSL: value-of select = "title"/> </a> </H2> <ul> <XSL: apply-templates select = "item"/> </ul> </XSL: Template> <XSL: template match = "item"> <li> <a href = "{link}" target = "_ blank"> <XSL: value-of select = "title"/> </a>-<XSL: value-of select = "pubdate"/> <br/> <XSL: value-of disable-output-escaping = "yes" select = "Description"/> <p/> </LI> </XSL: Template> </XSL: stylesheet>

III,ASP: sitemapdatasource: used for page navigation:

1. Compile an XML text file called Web. sitemap, which defines the structural hierarchy of the entire page to be navigated;

2. AddSitemapdatasourceControl. This control automatically binds content in Web. sitemap;

3. SetSitemapdatasourceControls are bound to controls such as sitemappath, Treeview, and menu;

4. For details about the XML controls on the client, see DSO.

5. other server-side controls:

1. template control:

 

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "datalist_xml_nested.aspx.cs" inherits = "datalist_xml_nested" %> <! 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"> 

2. Non-template controls:

 

 

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "gridview_xml.aspx.cs" inherits = "gridview_xml" %> <! 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"> 

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.