甚至:
/*/*
這會選擇XML文檔的頂層元素(在您的案例中名爲parent
)的所有元素 - 子元素。
XSLT - 基於驗證:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="/*/*"/>
</xsl:template>
</xsl:stylesheet>
當這個變換所提供的XML文檔施加:
<parent>
<child1>
<data1>some data</data1>
</child1>
<child2>
<data2>some data</data2>
</child2>
<child3>
<data3>some data</data3>
</child3>
</parent>
XPath表達式求值和所選擇的節點輸出:
<child1>
<data1>some data</data1>
</child1>
<child2>
<data2>some data</data2>
</child2>
<child3>
<data3>some data</data3>
</child3>
[this]中的'child'(http://www.w3schools.com/xsl/xpath_axes.asp)可能會有幫助。 – shellbye