现在我有个问题就是在xml里面链接一个css文件应该怎么写?

解决方案 »

  1.   

    我有两个问题:
    第一:想请大家看看这个xml文件中有没有什么错误,有哪些地方还需改进;
    第二:我在写完xml文件的时候,在浏览器中查看,在页面中了发现xml中的元素同时也显示了出来。如果我不想让xml中的元素如<课程信息>不在浏览器显示出来是不是得写css?
      

  2.   


    你这个 无法加入css
      因为css不支持汉字标签 可以使用xsl来格式化  用Altova XMLSpy工具很简单的 有汉化版  写xsl的时候有提示
      

  3.   

    写个英文标签 中间放个连接地址。
    <?xml version="1.0" encoding="gb2312"?>
    <?xml-stylesheet type="text/xsl" title="XSL Formatting" href="../rss.xslt"?>
    <rss version="2.0">
    <channel>
    <title><![CDATA[TOM网-篮球]]></title>
    <image>
    <title>www.tom.com</title>
    <link>http://www.tom.com</link>
    <url>http://tom.com/img/tom_logo.gif</url>
    </image>
    <description></description>
    <link>http://nba.sports.tom.com/lqsk/index.html</link>
    <language>zh-cn</language>
    <docs>sp03J1</docs>
    <generator>www.tom.com</generator>
    <ttl>5</ttl>
    <pubDate>2008-11-11 16:32:30</pubDate>
    </channel>
    </rss>
      

  4.   

    是呀,XML的各个节点最好用英文的,中文的在有些地方不能正常显示啊。
      

  5.   

    我有两个问题: 
    第一:想请大家看看这个xml文件中有没有什么错误,有哪些地方还需改进; 
    第二:我在写完xml文件的时候,在浏览器中查看,在页面中了发现xml中的元素同时也显示了出来。如果我不想让xml中的元素如 <课程信息>不在浏览器显示出来是不是得写css?
      

  6.   

    不知道你要链接CSS是什么意思
      

  7.   

    加个节点不就可以了吗,里面的值就用CSS在本地的相对路径,在程序中映射该节点的值,连接到页面中不就OK了
      

  8.   

    正在开始学习xml
    楼主一起努力啊
      

  9.   

    xml不是在外部配置的吗...接分!
      

  10.   

    楼主是不是将xml中的内容表格的显示显示在浏览器中?
      

  11.   

    帖子太长没看完  我一些XML XSLT CSS 相互调用的小例子  希望对楼主有帮助<!-- Report.xsl文件-->
    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
      <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" encoding="Shift_JIS" />  <xsl:template match="/">
        <link href="./commonCSS.css" rel="stylesheet" type="text/css" />
        <html>
          <div>
            <head>
                <!-- StaticText1 -->
                <span id="TXT_StaticText1" class="headstyle" style="left:7.7cm; top:2.35cm;">
                  <xsl:value-of select="ReportRoot/ReportPage1/ReportHead/StaticText1" />
                </span>
            </head>
            <body> 
              <!-- StaticText2 -->
              <span id="TXT_StaticText2" class="bodystyle" style="left:1.8cm; top:6.35cm;">
                <xsl:value-of select="ReportRoot/ReportPage1/ReportBody/StaticText2" />
              </span>
              <!-- StaticText3 -->
              <span id="TXT_StaticText3" class="bodystyle" style="left:13.8cm; top:6.35cm;">
                <xsl:value-of select="ReportRoot/ReportPage1/ReportBody/StaticText3" />
              </span>          
            </body>
          </div>
        </html>
      </xsl:template>
    </xsl:stylesheet><!-- Report.XML文件-->
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <?xml-stylesheet type='text/xsl' href='./Report.xsl'?>
    <ReportRoot name="Report">
    <ReportPage1>
    <ReportHead>
    <StaticText1>StaticText1</StaticText1>
    </ReportHead>
    <ReportBody>
    <StaticText2>StaticText2</StaticText2>
    <StaticText3>StaticText3</StaticText3>
    </ReportBody>
    </ReportPage1>
    </ReportRoot>
    <!-- commonCSS.css文件-->
    .headstyle
    {
    position:absolute;
    color:Black;
    font-size:14pt;
    }
    .bodystyle
    {
    position:absolute;
    color:Black;
    font-size:11pt;
    }
    将以上文件保存到同一文件夹  看一下效果就明白了
      

  12.   

    稍微在说一下  Report.xsl  编码改一下 encoding="Shift_JIS" ——>encoding="utf-8"用IE打开XML预览一下吧
      

  13.   

    xml文件可以用css呈现,也可以用xsl呈现 
    给你一个css呈现的例子。
    data.xml:
    <?xml version="1.0" encoding="GB2312" ?><?xml-stylesheet href="first.css" type="text/css"  ?><data><book><title>XML入门精解</title><author>张三</author><price unit="人民币">20.00</price></book><book><title>XML语法</title><!-- 即将出版 --><author>李四</author><price unit="人民币">18.00</price><memo>此书是著名计算机科学专家编著,极具权威性。在书中又穿插许多精彩的例子,所以可读性又极强。</memo></book></data>first.css:
    data  {
    background-color: #FFCC99;
    width: 80%;
    }
    book {
    display: block;
    border: 2px solid green;
    margin-bottom: 20pt;
    margin-left: 20pt;
    margin-top: 20pt;
    margin-right: 20pt;
    }
    title {
    display: block;
    color: blue;
    font-size: 16pt;
    }
    price {
    display: block;
    color: red;
    font-size: 16pt;
    }
    memo {
    display: block;
    text-align: center; 
    color: green;
    margin-left: 20pt;
    font-size: 12pt;
    }