亲爱的朋友们,下午好.我的问题可能是非常基本的问题,即如何使用xslt从xml文件中删除根元素.下面给出的Xml文件示例.
<Result>
<Jobs id="1">
<Job ID="000000" PositionID="0000">
<Title>Development Manager - Investment Banking - Equities Business</Title>
<Summary><![CDATA[An experienced Development Manager with previous experience leading a small to mid-size team of developers in a Java/J2EE environment. A hands on role, you will be expected to manage and mentor a team of developers working on a mix of greenfield and maintenance projects.   My client, a well known investment bank, requires an experienced Development Manager to join their core technology team. This t]]></Summary>
<DateActive Date="2009-10-06T19:36:43-05:00">10/6/2009</DateActive>
<DateExpires Date="2009-11-05T20:11:34-05:00">11/5/2009</DateExpires>
<DateUpdated Date="2009-10-06 20:12:00">10/6/2009</DateUpdated>
<CompanyName>ABC Technology</CompanyName>
</Job>
</Jobs>
</Result>
Run Code Online (Sandbox Code Playgroud)
所以,我想要输出如下
<Jobs>
<Job ID="000000" PositionID="0000">
<Title>Development Manager - Investment Banking - Equities Business</Title>
<Summary><![CDATA[An experienced Development Manager with previous experience leading a small to mid-size team of developers in a Java/J2EE environment. A hands on role, you will be expected to manage and mentor a team of developers working on a mix of greenfield and maintenance projects.   My client, a well known investment bank, requires an experienced Development Manager to join their core technology team. This t]]></Summary>
<DateActive Date="2009-10-06T19:36:43-05:00">10/6/2009</DateActive>
<DateExpires Date="2009-11-05T20:11:34-05:00">11/5/2009</DateExpires>
<DateUpdated Date="2009-10-06 20:12:00">10/6/2009</DateUpdated>
<CompanyName>ABC Technology</CompanyName>
</Job>
</Jobs>
Run Code Online (Sandbox Code Playgroud)
所以,不再
<Result></Result>
Run Code Online (Sandbox Code Playgroud)
xml文件中的标签.PLS.救命.提前致谢.
Tom*_*lak 11
<!-- identity template -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<!-- template for the document element -->
<xsl:template match="/*">
<xsl:apply-templates select="node()" />
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
身份模板按原样复制所有内容,而文档元素的模板仅处理子节点(将它们交给身份模板),而不复制根节点本身.
如果您<summary>出于某种原因想要保留CDATA,则需要
<xsl:output cdata-section-elements="summary" />
Run Code Online (Sandbox Code Playgroud)