我有这样的事情:
<body>
foo bar foo bar foo bar...
<p>foo bar!</p>
<div class="iWantYourContent">
<p>baz</p>
</div>
</body>
我想要这个输出:
<body>
foo bar foo bar foo bar...
<p>foo bar!</p>
<p>baz</p>
</body>
我已经设法使用以下方法获取节点的内容:
<xsl:template match="/">
<xsl:apply-templates select="//x:div[@class = 'iWantYourContent']"/>
</xsl:template>
<xsl:template match="//x:div[@class = 'iWantYourContent']">
<body>
<xsl:copy-of select="node()"/>
</body>
</xsl:template>
但我无法保留文件的其余部分。
感谢您的帮助。