Convert XML data to HTML

Source: Internet
Author: User
You can use a simple XSL style sheet to convert XML data into HTML. With the continuous evolution of XML specifications, it seems necessary to meet the needs of everyone in the new version. suppose there is an XML data that represents the content of a page, now I want Apply a simple XSLThe style sheet can convert XML data HTML. With the continuous evolution of XML specifications, it seems necessary to meet the needs of everyone in the new version. suppose there is an XML data that represents the content of a page, now I want to convert the content to layout. The XML to be converted is as follows:






Folder 1


File 1



String
50
Some data








This content represents a group of folders, files, and domains. Each folder contains files, and each file contains the fields used for data input. Each folder in the folder group is represented as a TR element and a TD element in the first row of a TABLE. Each file in the file Group is represented as a TR element and a TD element in the first row of a TABLE element nested in the TR element of the folder. Each domain in the Domain Group is represented as an INPUT in the coherent file.

The following is the XSL used for this conversion:



Xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0"
Xmlns: msxsl = "urn: schemas-microsoft-com: xslt"
Xmlns: fn = http://www.aaa.com/aaa>


Function getElementCount (nodelist, what ){
Var rtrn = 0;
Rtrn = nodelist [0]. parentNode. selectNodes (what). length;
Return (rtrn 1); // 1 is added for filler TD
}



WIDTH = "100%" BORDER = "0" ID = "tblRoot" NAME = "tblRoot"
Style = "table-layout: fixed;">



Width: 55px



 









WIDTH = "100%" BORDER = "0" style = "table-layout: fixed;">



Width: 55px;

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.