xslt – 如何从xml文件中删除根元素

前端之家收集整理的这篇文章主要介绍了xslt – 如何从xml文件中删除根元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
亲爱的朋友们,下午好.我的问题可能是这是非常基本的问题,即我们如何使用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.&#160;&#160; 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>

所以,我想要输出如下

<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,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></Result>

xml文件中的标签. PLS.救命.提前致谢.

<!-- 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>

身份模板按原样复制所有内容,而文档元素的模板仅处理子节点(将它们交给身份模板),而不复制根节点本身.

如果你想保留你的< summary>由于某种原因,你需要CDATA

<xsl:output cdata-section-elements="summary" />
原文链接:https://www.f2er.com/xml/292123.html

猜你在找的XML相关文章