繁体   English   中英

XSLT显示XML标记之间的所有文本

[英]XSLT Display all text Between XML tags

我是使用XSLT的新手,但我一直在努力解决问题。 我想打印出xml标记之间的文本。

XML代码

<?xml version="1.0" encoding="UTF-8"?>
<generic-cv:generic-cv xmlns:generic-cv="http://www.cihr-irsc.gc.ca/generic-cv/1.0.0" lang="en" dateTimeGenerated="2014-05-30 11:40:50">
<section id="f589cbc028c64fdaa783da01647e5e3c" label="Personal Information">
    <section id="2687e70e5d45487c93a8a02626543f64" label="Identification" recordId="4f7c2ebd789f407b939e05664f6aa7c0">
        <field id="ee8beaea41f049d8bcfadfbfa89ac09e" label="Title">
            <lov id="00000000000000000000000000000318">Mr.</lov>
        </field>
        <field id="5c6f17e8a67241e19667815a9e95d9d0" label="Family Name">
            <value type="String">ali</value>
        </field>
        <field id="98ad36fee26a4d6b8953ea764f4fed04" label="First Name">
            <value type="String">Hara</value>
        </field>
        <field id="4ca83c1aaa6a42a78eac0290368e70f3" label="Middle Name">
            <value type="String"/>
        </field>
        <field id="41ed5ea3ae974428b3fcb592161b6423" label="Date of Birth">
            <value format="MM/dd" type="MonthDay">8/23</value>
        </field>
        <field id="2b72a344523c467da0c896656b5290c0" label="Correspondence language">
            <lov id="00000000000000000000000000000054">English</lov>
        </field>
    </section>
</section>

xslt代码

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>

    <xsl:template match="/">
      <html>
         <head>
            <title>Xml Convertor</title>
        </head>
        <body>
          <h2><b> Personal Information</b></h2>
              <ul>
                    <li>Name:</li>
                    <li> Date of Birth:</li>
                    <li> Language:</li>

                  </ul>         

        </body>
        </html>
</xsl:template>

</xsl:stylesheet>

到目前为止,我尝试使用的是

    <xsl:value-of select="concat('&lt;',name(parent::*),'> ',.,'&#xA;')"/>

但这会打印出标签之间的所有信息

我希望输出像

Name: Hara ali
Date of Birth: 8/23 
Language: English

如何使用xslt做到这一点?

谢谢!

可以使用xsl:value-of接收来自节点的文本,您将希望通过其标签选择字段,例如:

<xsl:value-of select=".//field[@label='First Name']/value" />

您应该能够自己得到其余的东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM