简体   繁体   中英

Select all elements and sub-elements in XML using XSLT

Hi I am trying to select all the elements and sub-elements in an XML with out Specifying certain path in XSLT.

My Sample XML is

<Home>
<Application>One</Application>
<Property>Valid</Property>
<PR>3254</PR>
<Trigger>
  <Interface>Temp</Interface>
  <Id>234</Id>
</Trigger>
</Home>

OutPut Expected is

Application : One
Property : Valid
PR : 3254
Interface : Temp
Id : 234

I have used the below XSLT

<xsl:for-each select="Home/*">
<xsl:value-of select="name()"/>
<xsl:value-of select="string(.)"/>
</xsl:for-each>

But Getting Result as follows

Application : One
Property : Valid
PR : 3254
Trigger: Temp234

Can anyone help me on this

尝试选择所有叶节点 (不具有子元素的节点),例如:

<xsl:for-each select="//*[not(*)]">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM