创建 HTML 表并使用 SQL FOR XML 指定字体大小
我需要编写 SQL 语句来返回 html 表并指定其内容的字体大小。
我在此处找到了一些信息。本主题的解决方案描述了如何获取包含元素但不包含属性的 XML:
<tr>
<th>Problem</th>
<th>Onset</th>
<th>Status</th>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
但是我需要编写返回如下内容的 SQL 语句:
<tr>
<th><font size="1">Problem</font></th>
<th><font size="1">Onset</font></th>
<th><font size="1">Status</font></th>
</tr>
<tr>
<td><font size="1">aaa</font></td>
<td><font size="1">bbb</font></td>
<td><font size="1">ccc</font></td>
</tr>
I need to write SQL statement that will return an html table and specify font size to its content.
I've found some information here. Solusion of this tipic describes how to get XML with elements but without attributes:
<tr>
<th>Problem</th>
<th>Onset</th>
<th>Status</th>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
But I need to write SQL statement that would return something like this:
<tr>
<th><font size="1">Problem</font></th>
<th><font size="1">Onset</font></th>
<th><font size="1">Status</font></th>
</tr>
<tr>
<td><font size="1">aaa</font></td>
<td><font size="1">bbb</font></td>
<td><font size="1">ccc</font></td>
</tr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一些想法。
1) 在应用程序中而不是在查询中将 SQL 数据转换为 XML。 .NET / PHP / Java 都有方法将 SQL 数据获取为 XML。
2) 使用 XSL 将 XML 从数据库转换为 HTML
3) 考虑使用 CSS 代替
标签。
A couple thoughts.
1) Convert your SQL data to XML in your application, not in the query. .NET / PHP / Java all have ways to get SQL data as XML.
2) Use XSL to transform the XML from the database to HTML
3) Consider using CSS instead of
<font>
tags.结果:
Result: