怎么用XPATH取出下面的内容

shangezi 2010-05-01 03:28:19

<table align="center" border="0" cellpadding="0" cellspacing="0" height="100%" id="mainTable" style="margin-bottom: 20px; MARGIN-LEFT: 20px; MARGIN-RIGHT: 20px; MARGIN-TOP: 0px; padding:15" width="95%">
<tr>
<td bgcolor="#FFFFFF" id="tdFormBody" valign="TOP">
<p> </p>
<form method="post" name="form"><font face="Arial"><font face="Arial"><font face="Arial"><font face="Arial"><font face="Arial"><font face="Arial"><font face="Arial">
<div id="colorDiv"/><font face="Arial">
<p align="center"><font color="red" size="4"><strong>请假单</strong></font> </p>
<p/>
<div>
<table align="center" border="1" bordercolor="buttontext" style="TABLE-LAYOUT: auto; BORDER-LEFT-COLOR: buttontext; BORDER-BOTTOM-COLOR: buttontext; WIDTH: 620px; BORDER-TOP-COLOR: buttontext; BORDER-COLLAPSE: collapse; HEIGHT: 231px; WORD-WRAP: break-word; BORDER-RIGHT-COLOR: buttontext">
<tbody>
<tr>
<td width="100%">
<p align="left"><font size="2">部门:<select id="field38" style="WIDTH: 128px"><option selected="" value="{{{auto}}}">系统赋值</option></select> </font><font size="2"> 职务:</font><input id="field9" maxlength="50" size="16" style="WIDTH: 122px; HEIGHT: 22px"/><font size="2"> 姓名:<select id="field39" style="WIDTH: 131px"><option selected="" value="{{{auto}}}">系统赋值</option></select></font></p></td></tr>
<tr>
<td width="100%">
<p align="left"><font size="2">请假类别: <input id="field11" type="checkbox"/>休假 <input id="field12" type="checkbox"/>公假 <input id="field13" type="checkbox"/>病假 <input id="field14" type="checkbox"/>其他(请说明) <input id="field16" type="checkbox"/>事假</font></p></td></tr>
<tr>
<td width="100%"><font size="2">请假时间: </font>
<p><font size="2">  自 </font><input id="field27" maxlength="50" size="3" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">年 </font><input id="field18" maxlength="50" size="4" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">月 </font><input id="field28" maxlength="50" size="3" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">日 </font><input id="field29" maxlength="50" size="3" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">时
<p>  至 </p></font><input id="field30" maxlength="50" size="4" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">年 </font><input id="field31" maxlength="50" size="3" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">月 </font><input id="field32" maxlength="50" size="3" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">日 </font><input id="field33" maxlength="50" size="3" style="WIDTH: 60px; HEIGHT: 22px"/> <font size="2">时</font>
</p><p><font size="2">                 总共请假:</font><input id="field34" maxlength="50" size="5" style="WIDTH: 100px; HEIGHT: 22px"/> <font size="2">天 </font><input id="field17" maxlength="50" size="5" style="WIDTH: 100px; HEIGHT: 22px"/> <font size="2">小时</font></p></td></tr>
<tr>
<td width="100%">
<p align="center"><font size="2"> 部门领导意见</font></p></td></tr>
<tr>
<td width="100%"><font size="2">   <input id="field21" type="checkbox"/>同意,领导签字</font><input id="field23" maxlength="50" size="18" style="WIDTH: 261px; HEIGHT: 22px"/><font size="2"> </font>
<p><font size="2">   <input id="field22" type="checkbox"/>不同意,(请述明理由) </font><input id="field24" maxlength="50" size="18" style="WIDTH: 400px; HEIGHT: 22px"/><font size="2"> </font>
</p><p align="right"><font size="2"> 签字:<select id="field40" style="WIDTH: 105px"><option selected="" value="{{{auto}}}">系统赋值</option></select></font><font size="2"> 日期:<input id="field42" maxlength="50" size="15" style="WIDTH: 123px; HEIGHT: 22px"/></font></p></td></tr></tbody></table></div>
<p/></font></font></font></font></font></font></font></font><div id="divInputs"><table id="mytable_input"><tr><td/></tr></table></div><div id="divSelects"><table id="mytable_select"><tr><td/></tr></table></div><div id="divFnMemberId" style="clear:both"/></form>
</td>
</tr>
</table>


像上面的一段代码,我想取有用的出来,因为这是一个公共的模块,可能其他table表示的跟上面的不一样,顺序还有字段都不同,所以我想问问,怎么弄个好的xsl模版,把所有不同的table里面的节点都能很好的排列好呢,先有些<font>标签里面的文字,中间有太多空格,我知道如果单针对一个table来做就很容易,但我要适应不同的表单,这又怎么做呢,请高手指点下

我现在只是这样来做
<xsl:template match="table">
<xsl:apply-templates select="tbody"/>
</xsl:template>

<xsl:template match="tbody">
<xsl:apply-templates select="tr"/>
</xsl:template>

<xsl:template match="tr">
<xsl:apply-templates select="td"/>
</xsl:template>

<xsl:template match="td">
<xsl:apply-templates/><br/>
</xsl:template>

<xsl:template match="font">
<xsl:apply-templates/><br/>
</xsl:template>

一层层的找下去,但我不知道怎么去掉一些空格,例如我想在<font>的标签的时候,去掉一些没用的空格,不知道怎么做



...全文
80 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧