现在我有个问题就是在xml里面链接一个css文件应该怎么写?
解决方案 »
- 如何远程获取html源码,不从缓存中读取?
- C# 设置DirectX 3D中摄像头
- SQL数据库查询指定日期范围内数据
- C#中List.Clear()方法清除元素的问题
- 求救! 怎样把textBox内容与数据库数据比较?
- 求GDI+方面的电子资料,学习文档编程案例均可,谢谢!!
- 关于在C#中using的使用
- 新人写的便利贴,可以一起交流啊,改进神马的,大神给我点建议啊!
- 谁能提供些dotnet下多线程,守护线程,线程引擎方面的资料,!
- 用C#如何实现像拼图游戏那样的,可以用鼠标拖动改变图形位置的功能?
- 急求:List<Object>列表递归算法的代码
- 如何添加ReportControl.dll的引用?
第一:想请大家看看这个xml文件中有没有什么错误,有哪些地方还需改进;
第二:我在写完xml文件的时候,在浏览器中查看,在页面中了发现xml中的元素同时也显示了出来。如果我不想让xml中的元素如<课程信息>不在浏览器显示出来是不是得写css?
你这个 无法加入css
因为css不支持汉字标签 可以使用xsl来格式化 用Altova XMLSpy工具很简单的 有汉化版 写xsl的时候有提示
<?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>
第一:想请大家看看这个xml文件中有没有什么错误,有哪些地方还需改进;
第二:我在写完xml文件的时候,在浏览器中查看,在页面中了发现xml中的元素同时也显示了出来。如果我不想让xml中的元素如 <课程信息>不在浏览器显示出来是不是得写css?
楼主一起努力啊
<?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;
}
将以上文件保存到同一文件夹 看一下效果就明白了
给你一个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;
}