xml用到的css代码只能写到外部文件吗?能不能像html一样,写在本页里。

解决方案 »

  1.   

    可以像html一样,直接插入XML文件中。不过通常的情况下采用外部的CSS样式文件显示XML文件内容。
      

  2.   

    这是《xml网页制作..》中的一个例子:
    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type="text/css"?>
    <!--网页制作彻底研究系列-->
    <booklist>
    <HTML:STYLE xmlns:HTML="http://www.w3.org/1999/xhtml">
    booklist {
    background-color: #FFCC99;
    width: 80%;
    }
    book {
    display: block;
    border: 2px solid green;
    margin-bottom: 20pt;
    margin-left: 20pt;
    margin-top: 20pt;
    margin-right: 20pt;
    }
    code {
    display: inline;
    color: blue;
    font-size: 16pt;
    }
    title {
    display: inline;
    color: red;
    font-size: 16pt;
    }
    author, price {
    display: block;
    text-align: center; 
    color: green;
    margin-left: 20pt;
    font-size: 12pt;
    }
    </HTML:STYLE>
       <book>
          <code>F8915</code>
          <title>ASP网页制作彻底研究</title>
          <authorlist>
              <author>陈会安</author>
          </authorlist>
          <price>580</price>
       </book>
       <book>
          <code>F8916</code>
          <title>ASP与IIS 4/5网站架设彻底研究</title>
          <authorlist>
              <author>陈会安</author>
          </authorlist>
          <price>550</price>
       </book>
    </booklist>