我有XML数据,我想在浏览器中使用XSL文件显示,因为它是我应该怎么做。在下面的数据我想显示评论。数据是:
<RESULT_COMMENTS>EBV Acute EBV Acute Infection Antibodies
Reported: 11/23/2016 18:08 Status=F
--------------------------------------------------------------------------------
TEST RESULT FLAG RANGE UNITS SC
--------------------------------------------------------------------------------
EBV Ab VCA, IgM <36.0 0.0-35.9 U/mL RN 11/23/16.1808.rf
Negative <36.0
Equivocal 36.0 - 43.9
Positive >43.9
EBV Early Antigen Ab, IgG <9.0 0.0-8.9 U/mL RN 11/23/16.1808.rf
Negative < 9.0
Equivocal 9.0 - 10.9
Positive >10.9
EBV Ab VCA, IgG <18.0 0.0-17.9 U/mL RN 11/23/16.1808.rf
Negative <18.0
Equivocal 18.0 - 21.9
Positive >21.9
EBV Nuclear Antigen Ab, <18.0 0.0-17.9 U/mL RN 11/23/16.1808.rf
IgG
Negative <18.0
Equivocal 18.0 - 21.9
Positive >21.9
Interpretation: RN 11/23/16.1808.rf</RESULT_COMMENTS>
答案 0 :(得分:0)
通过“显示数据,因为它”,您的意思并不十分清楚。我原本希望用空格填充表格,这样当以单倍间距字体显示时,列将对齐。这很容易使用:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="RESULT_COMMENTS">
<pre>
<xsl:value-of select="."/>
</pre>
</xsl:template>
</xsl:stylesheet>
结果如下:
EBV Acute EBV Acute Infection Antibodies
Reported: 11/23/2016 18:08 Status=F
--------------------------------------------------------------------------------
TEST RESULT FLAG RANGE UNITS SC
--------------------------------------------------------------------------------
EBV Ab VCA, IgM <36.0 0.0-35.9 U/mL RN 11/23/16.1808.rf
Negative <36.0
Equivocal 36.0 - 43.9
Positive >43.9
EBV Early Antigen Ab, IgG <9.0 0.0-8.9 U/mL RN 11/23/16.1808.rf
Negative < 9.0
Equivocal 9.0 - 10.9
Positive >10.9
EBV Ab VCA, IgG <18.0 0.0-17.9 U/mL RN 11/23/16.1808.rf
Negative <18.0
Equivocal 18.0 - 21.9
Positive >21.9
EBV Nuclear Antigen Ab, <18.0 0.0-17.9 U/mL RN 11/23/16.1808.rf
IgG
Negative <18.0
Equivocal 18.0 - 21.9
Positive >21.9
Interpretation: RN 11/23/16.1808.rf
如您所见,结果并未完美格式化。但是,我相信这是你在这种情况下能做的最好的事情 - 除非你愿意投入大量资金将数据解析成单个单元格并将其呈现在HTML表格中。在任何情况下, 显示数据“按原样” - 无论好坏。