A site map for transforming XSLT into XML

Source: Internet
Author: User
Tags xsl xslt

How does. Net (C #) generate xml?

 

XML generated by. Net: menu. xml

<Root>
<Treenode Title = "zeditor1" href = "http://www.google.cn/" target = "_ blank">

<Treenode Title = "zeditor01" href = http://www.yahoo.com.cn/"target =" _ blank "/>

</Treenode>
<Treenode Title = "zeditor2" href = "http://www.baidu.com/target =" _ blank "/>
</Root>

 

XSLT: sitemenu. XSL

 

<? XML version = "1.0" encoding = "UTF-8"?>

<XSL: stylesheetversion = "1.0"
Xmlns: XSL = "http://www.w3.org/1999/XSL/Transform">

<XSL: template match = "root">
<XSL: Apply-templates/>
</XSL: Template>
<XSL: template match = "treenode">
<Ul style = "list-style: none; margin: 0px 20px;">
<XSL: For-each select = ".">
<Li style = "list-style: none;">
<A>
<XSL: attribute name = "href">
<XSL: value-of select = "@ href"/>
</XSL: attribute>
<XSL: attribute name = "target">
<XSL: value-of select = "@ target"/>
</XSL: attribute>
<XSL: value-of select = "@ title"/>
</A>
<XSL: Apply-templates/>
</LI>
</XSL: For-each>
</Ul>

</XSL: Template>
</XSL: stylesheet>

After generation, parse through JS:

Loadxml ("menu. XML," sitemenu. XSL ");
Function loadxml (xmlf, xslf)
{

Try
{
VaR myxml = new activexobject ("msxml2.freethreadeddomdocument ");
Myxml. async = false;
Myxml. Load (xmlf );

 

VaR myxsl = new activexobject ("msxml2.freethreadeddomdocument ");
Myxsl. async = false;
Myxsl. Load (using F );
Html = myxml. transformnode (myxsl );
Document. Write (HTML );

}
Catch (exception)
{
Alert (exception. Description );
}
}

 

 

 

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.