w3pop.com :: ÍøÂçѧԺ :: XML :: Óà CSS ÏÔʾ XML
With CSS (Cascading Style Sheets) you can add display information to an XML document.
ÀûÓÃCSS£¨²ãµþÑùʽ±í£©£¬Äã¿ÉÒÔ¸øXMLÎļþÌí¼ÓÏÔʾÐÅÏ¢¡£
It is possible to use CSS to format an XML document.
¿ÉÒÔÓÃCSS´¦ÀíXMLµÄÎĵµ²¼¾Ö¡£
Below is an example of how to use a CSS style sheet to format an XML document:
ÏÂÃæÊÇʹÓÃCSSÑùʽ±í´¦ÀíXMLÎļþ²¼¾ÖµÄ°¸Àý£º
Take a look at this XML file: The CD catalog
Çë¿´Õâ¸öXMLÎļþ: CDĿ¼
Then look at this style sheet: The CSS file
ÔÙ¿´¶ÔÓ¦µÄÑùʽ±í: CSSÎļþ
Finally, view: The CD catalog formatted with the CSS file
×îºó£¬¿´µ½µÄÊÇ Í¨¹ýCSS²¼¾ÖºóµÄCDĿ¼ ¡£
Below is a fraction of the XML file. The second line, <?xml-stylesheet type="text/css" href="cd_catalog.css"?>, links the XML file to the CSS file:
ÏÂÃæÁоٵÄÊÇÕâ·ÝXMLÎļþÖÐµÄÆäÖÐÒ»¸ö´úÂë¶Î¡£µÚ¶þÐÐÓï¾ä£º<?xml-stylesheet type="text/css" href="cd_catalog.css"?>£¬ÒâÖ¸°ÑXMLÎļþÁ´½Óµ½CSSÎļþÖУº
<?xml version="1.0" encoding="ISO-8859-1"?> |
Note: Formatting XML with CSS is NOT the future of how to style XML documents. XML document should be styled by using the W3C's XSL standard!
×¢Ò⣺ÓÃCSS¸ñʽ»¯XMLÎĵµ²¢²»ÊǶÔXMLÎĵµ½øÐв¼¾ÖµÄ³¤¾ÃÖ®¼Æ¡£XMLÎļþÓ¦¸ÃʹÓÃW3C's XSL ±ê×¼½øÐÐÑùʽ¶¨ÒåºÍ²¼¾Ö¡£