我基本上需要弄清楚如何选择div的内部,并将其内部的所有HTML元素显示为HTML元素。我尝试过的所有操作都导致显示纯文本或保留外部div。
我已经尝试过了:
<xsl:template match="content">
<xsl:apply-templates select='*'/>
</xsl:template>
我也尝试过这个:
<xsl:template match="content/div/*">
<xsl:value-of select="*"/>
</xsl:template>
示例1:潜在的XML内容:
<content>
<div id="definition" class="block">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid reprehenderit consequatur voluptatem harum laudantium! Repellat nam laborum ipsum possimus, corrupti voluptate, iste odio vero nesciunt culpa assumenda nihil ducimus accusantium.</p>
</div>
</content>
示例2:潜在的XML内容:
<content>
<div id="definition" class="block">
<ul>
<li>Lorem ipsum dolor.</li>
<li>Sit amet consectetur.</li>
<li>Adipisicing elit.</li>
<li>Aliquid reprehenderit.</li>
</ul>
</div>
</content>
我需要XSLT来像这样简单地提取div中的HTML元素...
对于示例1:
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid reprehenderit consequatur voluptatem harum laudantium! Repellat nam laborum ipsum possimus, corrupti voluptate, iste odio vero nesciunt culpa assumenda nihil ducimus accusantium.</p>
对于示例2:
<ul>
<li>Lorem ipsum dolor.</li>
<li>Sit amet consectetur.</li>
<li>Adipisicing elit.</li>
<li>Aliquid reprehenderit.</li>
</ul>
答案 0 :(得分:1)
尝试:
<xsl:template match="content/div">
<xsl:copy-of select="*"/>
</xsl:template>